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() {
await super.load();
type clusterStateSync = {
id: string;
state: ClusterState;
};
try {
await super.load();
if (ipcRenderer) {
logger.info("[CLUSTER-STORE] requesting initial state sync");
const clusterStates: clusterStateSync[] = await requestMain(ClusterStore.stateRequestChannel);
type clusterStateSync = {
id: string;
state: ClusterState;
};
clusterStates.forEach((clusterState) => {
const cluster = this.getById(clusterState.id);
if (ipcRenderer) {
logger.info("[CLUSTER-STORE] requesting initial state sync");
const clusterStates: clusterStateSync[] = await requestMain(ClusterStore.stateRequestChannel);
if (cluster) {
cluster.setState(clusterState.state);
}
});
} else {
handleRequest(ClusterStore.stateRequestChannel, (): clusterStateSync[] => {
const states: clusterStateSync[] = [];
clusterStates.forEach((clusterState) => {
const cluster = this.getById(clusterState.id);
this.clustersList.forEach((cluster) => {
states.push({
state: cluster.getState(),
id: cluster.id
});
if (cluster) {
cluster.setState(clusterState.state);
}
});
} 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() {
await super.load();
type workspaceStateSync = {
id: string;
state: WorkspaceState;
};
try {
await super.load();
type workspaceStateSync = {
id: string;
state: WorkspaceState;
};
if (ipcRenderer) {
logger.info("[WORKSPACE-STORE] requesting initial state sync");
const workspaceStates: workspaceStateSync[] = await requestMain(WorkspaceStore.stateRequestChannel);
if (ipcRenderer) {
logger.info("[WORKSPACE-STORE] requesting initial state sync");
const workspaceStates: workspaceStateSync[] = await requestMain(WorkspaceStore.stateRequestChannel);
workspaceStates.forEach((workspaceState) => {
const workspace = this.getById(workspaceState.id);
workspaceStates.forEach((workspaceState) => {
const workspace = this.getById(workspaceState.id);
if (workspace) {
workspace.setState(workspaceState.state);
}
});
} else {
handleRequest(WorkspaceStore.stateRequestChannel, (): workspaceStateSync[] => {
const states: workspaceStateSync[] = [];
this.workspacesList.forEach((workspace) => {
states.push({
state: workspace.getState(),
id: workspace.id
});
if (workspace) {
workspace.setState(workspaceState.state);
}
});
} 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");
// preload
await Promise.all([
await Promise.allSettled([
userStore.load(),
clusterStore.load(),
workspaceStore.load(),