diff --git a/src/common/cluster-ipc.ts b/src/common/cluster-ipc.ts index e11a232ea3..6ab46c1489 100644 --- a/src/common/cluster-ipc.ts +++ b/src/common/cluster-ipc.ts @@ -14,6 +14,17 @@ export const clusterIpc = { }, }), + setFrameId: createIpcChannel({ + channel: "cluster:set-frame-id", + handle: (clusterId: ClusterId, frameId?: number) => { + const cluster = clusterStore.getById(clusterId); + if (cluster) { + if (frameId) cluster.frameId = frameId; // save cluster's webFrame.routingId to be able to send push-updates + return cluster.pushState(); + } + }, + }), + refresh: createIpcChannel({ channel: "cluster:refresh", handle: (clusterId: ClusterId) => { diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 12acb793ab..3e3ba3f6b5 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -59,6 +59,7 @@ export class Cluster implements ClusterModel { @observable online = false; @observable accessible = false; @observable ready = false; + @observable reconnecting = false; @observable disconnected = true; @observable failureReason: string; @observable nodes = 0; @@ -110,7 +111,7 @@ export class Cluster implements ClusterModel { protected bindEvents() { logger.info(`[CLUSTER]: bind events`, this.getMeta()); - const refreshTimer = setInterval(() => this.online && this.refresh(), 30000); // every 30s + const refreshTimer = setInterval(() => !this.disconnected && this.refresh(), 30000); // every 30s this.eventDisposers.push( reaction(this.getState, this.pushState), diff --git a/src/renderer/bootstrap.tsx b/src/renderer/bootstrap.tsx index 37fdc35e03..f03df719b6 100644 --- a/src/renderer/bootstrap.tsx +++ b/src/renderer/bootstrap.tsx @@ -11,7 +11,7 @@ import { App } from "./components/app"; import { LensApp } from "./lens-app"; type AppComponent = React.ComponentType & { - init?(): void; + init?(): Promise; } export async function bootstrap(App: AppComponent) { diff --git a/src/renderer/components/+cluster/cluster.tsx b/src/renderer/components/+cluster/cluster.tsx index 9ef032335b..9a1ce47123 100644 --- a/src/renderer/components/+cluster/cluster.tsx +++ b/src/renderer/components/+cluster/cluster.tsx @@ -14,14 +14,15 @@ import { podsStore } from "../+workloads-pods/pods.store"; import { clusterStore } from "./cluster.store"; import { eventStore } from "../+events/event.store"; import { isAllowedResource } from "../../../common/rbac"; +import { getHostedCluster } from "../../../common/cluster-store"; @observer export class Cluster extends React.Component { private dependentStores = [nodesStore, podsStore]; private watchers = [ - interval(60, () => clusterStore.getMetrics()), - interval(20, () => eventStore.loadAll()) + interval(60, () => { getHostedCluster().available && clusterStore.getMetrics()}), + interval(20, () => { getHostedCluster().available && eventStore.loadAll()}) ]; @computed get isLoaded() { diff --git a/src/renderer/components/app.tsx b/src/renderer/components/app.tsx index 053d8fa3d6..aee156ff31 100755 --- a/src/renderer/components/app.tsx +++ b/src/renderer/components/app.tsx @@ -44,8 +44,8 @@ export class App extends React.Component { const clusterId = getHostedClusterId(); logger.info(`[APP]: Init dashboard, clusterId=${clusterId}, frameId=${frameId}`) await Terminal.preloadFonts() - await clusterIpc.activate.invokeFromRenderer(clusterId, frameId); - await getHostedCluster().whenReady; // cluster.refresh() is done at this point + await clusterIpc.setFrameId.invokeFromRenderer(clusterId, frameId); + await getHostedCluster().whenReady; // cluster.activate() is done at this point } get startURL() {