Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen committed 2020-10-30 08:17:26 +02:00
1 parent a0682302eb
commit 614bf4e689
3 files changed
+10 -8

No files matched your search

+1 -1
View File
@@ -64,7 +64,7 @@ describe("empty config", () => {
it("sets active cluster", () => { it("sets active cluster", () => {
clusterStore.setActive("foo"); clusterStore.setActive("foo");
expect(clusterStore.activeCluster.id).toBe("foo"); expect(clusterStore.active.id).toBe("foo");
}) })
}) })
+9 -4
View File
@@ -73,6 +73,10 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
return filePath; return filePath;
} }
@observable activeCluster: ClusterId;
@observable removedClusters = observable.map<ClusterId, Cluster>();
@observable clusters = observable.map<ClusterId, Cluster>();
private constructor() { private constructor() {
super({ super({
configName: "lens-cluster-store", configName: "lens-cluster-store",
@@ -80,17 +84,18 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
migrations: migrations, migrations: migrations,
}); });
this.pushStateToViewsPeriodically()
}
protected pushStateToViewsPeriodically() {
if (!ipcRenderer) { 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(() => { setInterval(() => {
this.pushState() this.pushState()
}, 5000) }, 5000)
} }
} }
@observable activeCluster: ClusterId;
@observable removedClusters = observable.map<ClusterId, Cluster>();
@observable clusters = observable.map<ClusterId, Cluster>();
registerIpcListener() { registerIpcListener() {
logger.info(`[CLUSTER-STORE] start to listen (${webFrame.routingId})`) logger.info(`[CLUSTER-STORE] start to listen (${webFrame.routingId})`)
ipcRenderer.on("cluster:state", (event, clusterId: string, state: ClusterState) => { ipcRenderer.on("cluster:state", (event, clusterId: string, state: ClusterState) => {
-3
View File
@@ -61,9 +61,6 @@ export interface IpcBroadcastParams<A extends any[] = any> {
} }
export function broadcastIpc({ channel, frameId, frameOnly, webContentId, filter, args = [] }: IpcBroadcastParams) { export function broadcastIpc({ channel, frameId, frameOnly, webContentId, filter, args = [] }: IpcBroadcastParams) {
if (!webContents) {
return
}
const singleView = webContentId ? webContents.fromId(webContentId) : null; const singleView = webContentId ? webContents.fromId(webContentId) : null;
let views = singleView ? [singleView] : webContents.getAllWebContents(); let views = singleView ? [singleView] : webContents.getAllWebContents();
if (filter) { if (filter) {