From 614bf4e6890b11cba9662342d01335acebf7bbf7 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Fri, 30 Oct 2020 08:17:26 +0200 Subject: [PATCH] fixes Signed-off-by: Jari Kolehmainen --- src/common/__tests__/cluster-store.test.ts | 2 +- src/common/cluster-store.ts | 13 +++++++++---- src/common/ipc.ts | 3 --- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/common/__tests__/cluster-store.test.ts b/src/common/__tests__/cluster-store.test.ts index 14b1707260..8c911298cc 100644 --- a/src/common/__tests__/cluster-store.test.ts +++ b/src/common/__tests__/cluster-store.test.ts @@ -64,7 +64,7 @@ describe("empty config", () => { it("sets active cluster", () => { clusterStore.setActive("foo"); - expect(clusterStore.activeCluster.id).toBe("foo"); + expect(clusterStore.active.id).toBe("foo"); }) }) diff --git a/src/common/cluster-store.ts b/src/common/cluster-store.ts index 543eed512d..838e6cc119 100644 --- a/src/common/cluster-store.ts +++ b/src/common/cluster-store.ts @@ -73,6 +73,10 @@ export class ClusterStore extends BaseStore { return filePath; } + @observable activeCluster: ClusterId; + @observable removedClusters = observable.map(); + @observable clusters = observable.map(); + private constructor() { super({ configName: "lens-cluster-store", @@ -80,17 +84,18 @@ export class ClusterStore extends BaseStore { migrations: migrations, }); + this.pushStateToViewsPeriodically() + } + + protected pushStateToViewsPeriodically() { if (!ipcRenderer) { + // This is a bit of a hack, we need to do this because we might loose messages that are sent before a view is ready setInterval(() => { this.pushState() }, 5000) } } - @observable activeCluster: ClusterId; - @observable removedClusters = observable.map(); - @observable clusters = observable.map(); - registerIpcListener() { logger.info(`[CLUSTER-STORE] start to listen (${webFrame.routingId})`) ipcRenderer.on("cluster:state", (event, clusterId: string, state: ClusterState) => { diff --git a/src/common/ipc.ts b/src/common/ipc.ts index a5dc21da65..97c4dd05cd 100644 --- a/src/common/ipc.ts +++ b/src/common/ipc.ts @@ -61,9 +61,6 @@ export interface IpcBroadcastParams { } export function broadcastIpc({ channel, frameId, frameOnly, webContentId, filter, args = [] }: IpcBroadcastParams) { - if (!webContents) { - return - } const singleView = webContentId ? webContents.fromId(webContentId) : null; let views = singleView ? [singleView] : webContents.getAllWebContents(); if (filter) {