diff --git a/src/common/base-store.ts b/src/common/base-store.ts index 0cc087eb9f..2551dd2499 100644 --- a/src/common/base-store.ts +++ b/src/common/base-store.ts @@ -116,7 +116,8 @@ export class BaseStore extends Singleton { protected async onModelChange(model: T) { if (ipcMain) { this.save(model); // save config file - broadcastIpc({ channel: this.syncChannel, args: [model] }); // broadcast to renderer views + broadcastIpc({ channel: this.syncChannel, args: [model] }); // send to all windows (BrowserWindow, webContents) + this.syncInSubFrames(model); // send to all sub-frames (cluster-view is managed inside iframe) } // send "update-request" to main-process if (ipcRenderer) { @@ -124,6 +125,23 @@ export class BaseStore extends Singleton { } } + protected async syncInSubFrames(model: T) { + const subFrames: number[] = []; + const { clusterStore } = await import("./cluster-store"); + clusterStore.clustersList.forEach(cluster => { + if (cluster.frameId) { + subFrames.push(cluster.frameId) + } + }); + subFrames.forEach(frameId => { + broadcastIpc({ + channel: this.syncChannel, + frameId: frameId, + args: [model], + }) + }) + } + @action protected fromStore(data: T) { this.data = data; diff --git a/src/common/cluster-ipc.ts b/src/common/cluster-ipc.ts index 5e1b86992b..e3024a69b0 100644 --- a/src/common/cluster-ipc.ts +++ b/src/common/cluster-ipc.ts @@ -3,7 +3,7 @@ import { ClusterId, clusterStore } from "./cluster-store"; import { tracker } from "./tracker"; export const clusterIpc = { - init: createIpcChannel({ + initView: createIpcChannel({ channel: "cluster:init", handle: async (clusterId: ClusterId, frameId: number) => { const cluster = clusterStore.getById(clusterId); diff --git a/src/renderer/components/app.tsx b/src/renderer/components/app.tsx index 0c3044fc12..abdef9b7f4 100755 --- a/src/renderer/components/app.tsx +++ b/src/renderer/components/app.tsx @@ -38,10 +38,11 @@ import { webFrame } from "electron"; @observer export class App extends React.Component { static async init() { + const frameId = webFrame.routingId; const clusterId = getHostedClusterId(); - logger.info(`[APP]: Init dashboard, clusterId=${clusterId}`) + logger.info(`[APP]: Init dashboard, clusterId=${clusterId}, frameId=${frameId}`) await Terminal.preloadFonts() - await clusterIpc.init.invokeFromRenderer(clusterId, webFrame.routingId); + await clusterIpc.initView.invokeFromRenderer(clusterId, frameId); await getHostedCluster().whenInitialized; }