1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

attempt to recover the ui after failing to load cluster store

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
Jim Ehrismann 2021-02-26 20:37:24 -05:00
parent b3176a6fc4
commit c19f0b182b
3 changed files with 61 additions and 50 deletions

View File

@ -124,36 +124,43 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
} }
async load() { async load() {
await super.load(); try {
type clusterStateSync = { await super.load();
id: string;
state: ClusterState;
};
if (ipcRenderer) { type clusterStateSync = {
logger.info("[CLUSTER-STORE] requesting initial state sync"); id: string;
const clusterStates: clusterStateSync[] = await requestMain(ClusterStore.stateRequestChannel); state: ClusterState;
};
clusterStates.forEach((clusterState) => { if (ipcRenderer) {
const cluster = this.getById(clusterState.id); logger.info("[CLUSTER-STORE] requesting initial state sync");
const clusterStates: clusterStateSync[] = await requestMain(ClusterStore.stateRequestChannel);
if (cluster) { clusterStates.forEach((clusterState) => {
cluster.setState(clusterState.state); const cluster = this.getById(clusterState.id);
}
});
} else {
handleRequest(ClusterStore.stateRequestChannel, (): clusterStateSync[] => {
const states: clusterStateSync[] = [];
this.clustersList.forEach((cluster) => { if (cluster) {
states.push({ cluster.setState(clusterState.state);
state: cluster.getState(), }
id: cluster.id
});
}); });
} else {
handleRequest(ClusterStore.stateRequestChannel, (): clusterStateSync[] => {
const states: clusterStateSync[] = [];
return states; this.clustersList.forEach((cluster) => {
}); states.push({
state: cluster.getState(),
id: cluster.id
});
});
return states;
});
}
} catch (error) {
logger.error("[CLUSTER-STORE] error loading: ", error);
this.fromStore();
this.isLoaded = true;
} }
} }

View File

@ -160,36 +160,40 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
} }
async load() { async load() {
await super.load(); try {
type workspaceStateSync = { await super.load();
id: string; type workspaceStateSync = {
state: WorkspaceState; id: string;
}; state: WorkspaceState;
};
if (ipcRenderer) { if (ipcRenderer) {
logger.info("[WORKSPACE-STORE] requesting initial state sync"); logger.info("[WORKSPACE-STORE] requesting initial state sync");
const workspaceStates: workspaceStateSync[] = await requestMain(WorkspaceStore.stateRequestChannel); const workspaceStates: workspaceStateSync[] = await requestMain(WorkspaceStore.stateRequestChannel);
workspaceStates.forEach((workspaceState) => { workspaceStates.forEach((workspaceState) => {
const workspace = this.getById(workspaceState.id); const workspace = this.getById(workspaceState.id);
if (workspace) { if (workspace) {
workspace.setState(workspaceState.state); workspace.setState(workspaceState.state);
} }
});
} else {
handleRequest(WorkspaceStore.stateRequestChannel, (): workspaceStateSync[] => {
const states: workspaceStateSync[] = [];
this.workspacesList.forEach((workspace) => {
states.push({
state: workspace.getState(),
id: workspace.id
});
}); });
} else {
handleRequest(WorkspaceStore.stateRequestChannel, (): workspaceStateSync[] => {
const states: workspaceStateSync[] = [];
return states; this.workspacesList.forEach((workspace) => {
}); states.push({
state: workspace.getState(),
id: workspace.id
});
});
return states;
});
}
} catch (error) {
logger.error("[WORKSPACE-STORE] error loading: ", { error });
} }
} }

View File

@ -103,7 +103,7 @@ app.on("ready", async () => {
logger.info("💾 Loading stores"); logger.info("💾 Loading stores");
// preload // preload
await Promise.all([ await Promise.allSettled([
userStore.load(), userStore.load(),
clusterStore.load(), clusterStore.load(),
workspaceStore.load(), workspaceStore.load(),