Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

pooling #20

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions js/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

const CHART_URL = 'https://cdn.openfin.co/embed-web/chart.html';
const TRADEVIEW_URL = 'https://www.tradingview.com/chart/?symbol=NASDAQ:AAPL';
const NEWS_URL = 'https://www.google.com/search?q=INDEXDJX:+.DJI';
const URLS_ARRAY = [CHART_URL, TRADEVIEW_URL, NEWS_URL];

export { CHART_URL, TRADEVIEW_URL, NEWS_URL, URLS_ARRAY };
20 changes: 20 additions & 0 deletions js/platform-provider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { generateExternalWindowSnapshot, restoreExternalWindowPositionAndState } from './external-window-snapshot.js';
import { URLS_ARRAY } from './constants.js';

//We have customized out platform provider to keep track of a specific notepad window.
//Look for the "my_platform_notes.txt" file and launch it in notepad or add another external window to this array
Expand All @@ -9,9 +10,28 @@ const externalWindowsToTrack = [
}
];

const pooledViews = {};
const createPooledView = async (url) => {
console.log('about to create');
const view = await fin.Platform.getCurrentSync().createView({ url }, fin.me.identity);
pooledViews[url] = view.identity.name;
};

fin.Platform.getCurrentSync().once('platform-snapshot-applied', () => URLS_ARRAY.forEach(createPooledView));

fin.Platform.init({
overrideCallback: async (Provider) => {
class Override extends Provider {
async createView(payload) {
const { opts } = payload;
if (!opts.name && pooledViews[opts.url]) {
console.log('replacing name');
opts.name = pooledViews[opts.url];
delete pooledViews[opts.url];
setTimeout(() => createPooledView(opts.url),1);
}
return super.createView(payload);
}
async getSnapshot() {
const snapshot = await super.getSnapshot();

Expand Down
11 changes: 5 additions & 6 deletions js/platform-window.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { html, render } from 'https://unpkg.com/[email protected]/lit-html.js';
import { getTemplates, storeTemplate, getTemplateByName, onStoreUpdate } from './template-store.js';
import { CHART_URL, TRADEVIEW_URL, NEWS_URL } from './constants.js';


window.addEventListener('DOMContentLoaded', () => {
console.log('dom content');

fin.me.on('layout-ready', async () => {
// Whenever a new layout is ready on this window (on init, replace, or applyPreset)
Expand All @@ -17,7 +20,6 @@ window.addEventListener('DOMContentLoaded', () => {
fin.Platform.Layout.init({containerId: CONTAINER_ID});
});

const CHART_URL = 'https://cdn.openfin.co/embed-web/chart.html';
const LAYOUT_STORE_KEY = 'LayoutMenu';
const SNAPSHOT_STORE_KEY = 'SnapshotMenu';
const CONTAINER_ID = 'layout-container';
Expand All @@ -42,17 +44,14 @@ class LeftMenu extends HTMLElement {
{
url: CHART_URL,
printName: 'OF Chart',
processAffinity: 'ps_1'
},
{
url: 'https://www.tradingview.com/chart/?symbol=NASDAQ:AAPL',
url: TRADEVIEW_URL,
printName: 'TradeView',
processAffinity: 'tv_1'
},
{
url: 'https://www.google.com/search?q=INDEXDJX:+.DJI&stick=H4sIAAAAAAAAAONgecRozC3w8sc9YSmtSWtOXmNU4eIKzsgvd80rySypFBLjYoOyeKS4uDj0c_UNkgsry3kWsfJ5-rm4Rrh4RVgp6Ll4eQIAqJT5uUkAAAA&source=lnms&sa=X&ved=0ahUKEwii_NWT9fzoAhU3mHIEHWy3AWIQ_AUIDSgA&biw=1280&bih=1366&dpr=1',
url: NEWS_URL,
printName: 'News',
processAffinity: 'mw_1'
}
];

Expand Down