Refactor ipc module (#1225)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2020-11-19 11:48:13 +02:00
1 parent c4b98534dc
commit 5aaacb21f9
20 files changed
+224 -242

No files matched your search

+7 -7
View File
@@ -1,13 +1,13 @@
import type { ClusterId } from "../common/cluster-store";
import { clusterStore } from "../common/cluster-store";
import { observable } from "mobx";
import { app, BrowserWindow, dialog, ipcMain, shell, webContents } from "electron"
import { app, BrowserWindow, dialog, shell, webContents } from "electron"
import windowStateKeeper from "electron-window-state"
import { extensionLoader } from "../extensions/extension-loader";
import { appEventBus } from "../common/event-bus"
import { subscribeToBroadcast } from "../common/ipc"
import { initMenu } from "./menu";
import { initTray } from "./tray";
import { Singleton } from "../common/utils";
import { clusterFrameMap } from "../common/cluster-frames";
export class WindowManager extends Singleton {
protected mainWindow: BrowserWindow;
@@ -63,7 +63,7 @@ export class WindowManager extends Singleton {
shell.openExternal(url);
});
this.mainWindow.webContents.on("dom-ready", () => {
extensionLoader.broadcastExtensions()
appEventBus.emit({name: "app", action: "dom-ready"})
})
this.mainWindow.on("focus", () => {
appEventBus.emit({name: "app", action: "focus"})
@@ -101,9 +101,9 @@ export class WindowManager extends Singleton {
protected bindEvents() {
// track visible cluster from ui
ipcMain.on("cluster-view:current-id", (event, clusterId: ClusterId) => {
subscribeToBroadcast("cluster-view:current-id", (event, clusterId: ClusterId) => {
this.activeClusterId = clusterId;
});
})
}
async ensureMainWindow(): Promise<BrowserWindow> {
@@ -130,7 +130,7 @@ export class WindowManager extends Singleton {
}
reload() {
const frameId = clusterStore.getById(this.activeClusterId)?.frameId;
const frameId = clusterFrameMap.get(this.activeClusterId)
if (frameId) {
this.sendToView({ channel: "renderer:reload", frameId });
} else {