mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
3bd484f92a
commit
287147a64d
@ -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()
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@ -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;
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user