added more routes, refactoring

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2020-07-15 14:09:31 +03:00
1 parent e5aff1fdc8
commit d20e61b3e2
22 files changed
+119 -58

No files matched your search

+3 -3
View File
@@ -25,14 +25,14 @@ export function broadcastMessage({ channel, filter }: IpcBroadcastOpts, ...args:
filter = webContent => webContent.getType() === "window"
}
webContents.getAllWebContents().filter(filter).forEach(webContent => {
logger.info(`[IPC]: broadcasting ${channel} to ${webContent.getType()}=${webContent.id}`);
logger.debug(`[IPC]: broadcasting ${channel} to ${webContent.getType()}=${webContent.id}`);
webContent.send(channel, ...args);
})
}
// fixme: support timeout
// todo: support timeout
export async function invokeMessage<T = any>(channel: IpcChannel, ...args: any[]): Promise<T> {
logger.info(`[IPC]: invoke channel "${channel}"`, { args });
logger.debug(`[IPC]: invoke channel "${channel}"`, { args });
return ipcRenderer.invoke(channel, ...args);
}
+9 -11
View File
@@ -24,7 +24,7 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
});
}
@observable currentWorkspace = WorkspaceStore.defaultId;
@observable currentWorkspaceId = WorkspaceStore.defaultId;
@observable workspaces = observable.map<WorkspaceId, Workspace>({
[WorkspaceStore.defaultId]: {
@@ -33,6 +33,10 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
}
});
@computed get currentWorkspace(): Workspace {
return this.getById(this.currentWorkspaceId);
}
@computed get workspacesList() {
return Array.from(this.workspaces.values());
}
@@ -41,12 +45,6 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
return this.workspaces.get(id);
}
@action
setCurrent(id: WorkspaceId) {
if (!this.getById(id)) return;
this.currentWorkspace = id;
}
@action
public saveWorkspace(workspace: Workspace) {
const id = workspace.id;
@@ -65,8 +63,8 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
if (id === WorkspaceStore.defaultId) {
throw new Error("Cannot remove default workspace");
}
if (id === this.currentWorkspace) {
this.currentWorkspace = WorkspaceStore.defaultId;
if (id === this.currentWorkspaceId) {
this.currentWorkspaceId = WorkspaceStore.defaultId;
}
this.workspaces.delete(id);
clusterStore.removeByWorkspaceId(id)
@@ -75,7 +73,7 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
@action
protected fromStore({ currentWorkspace, workspaces = [] }: WorkspaceStoreModel) {
if (currentWorkspace) {
this.currentWorkspace = currentWorkspace
this.currentWorkspaceId = currentWorkspace
}
if (workspaces.length) {
this.workspaces.clear();
@@ -87,7 +85,7 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
toJSON(): WorkspaceStoreModel {
return toJS({
currentWorkspace: this.currentWorkspace,
currentWorkspace: this.currentWorkspaceId,
workspaces: this.workspacesList,
}, {
recurseEverything: true