mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: sync in sub-frames for common-stores are broken
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
86e1e23ccd
commit
7cf7756d27
@ -116,7 +116,8 @@ export class BaseStore<T = any> 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<T = any> 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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user