1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2020-11-30 14:03:44 +02:00
parent 3bd484f92a
commit 287147a64d
2 changed files with 21 additions and 17 deletions

View File

@ -7,12 +7,9 @@ jest.mock("electron", () => {
getPath: () => "tmp",
getLocale: () => "en"
},
ipcRenderer: {
invoke: jest.fn(),
on: jest.fn()
},
ipcMain: {
handle: jest.fn()
handle: jest.fn(),
on: jest.fn()
}
};
});

View File

@ -49,9 +49,9 @@ export class Workspace implements WorkspaceModel, WorkspaceState {
}
getState(): WorkspaceState {
return {
return toJS({
enabled: this.enabled
};
});
}
pushState(state = this.getState()) {
@ -87,21 +87,28 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
async load() {
await super.load();
type workspaceStateSync = {
id: string;
state: WorkspaceState;
};
if (ipcRenderer) {
logger.info("[WORKSPACE-STORE] requesting initial state sync");
await requestMain(this.stateRequestChannel, (states: Map<string, WorkspaceState>) => {
states.forEach((state, id) => {
const workspace = this.getById(id);
if (workspace) {
workspace.setState(state);
}
});
const workspaceStates: workspaceStateSync[] = await requestMain(this.stateRequestChannel);
console.log(workspaceStates);
workspaceStates.forEach((workspaceState) => {
const workspace = this.getById(workspaceState.id);
if (workspace) {
workspace.setState(workspaceState.state);
}
});
} else {
handleRequest(this.stateRequestChannel, (): Map<string, WorkspaceState> => {
const states = new Map<string, WorkspaceState>();
handleRequest(this.stateRequestChannel, (): workspaceStateSync[] => {
const states: workspaceStateSync[] = [];
this.workspacesList.forEach((workspace) => {
states.set(workspace.id, workspace.getState());
states.push({
state: workspace.getState(),
id: workspace.id
});
});
return states;
});