diff --git a/src/common/base-store.ts b/src/common/base-store.ts index e34c9c1598..5261c604d6 100644 --- a/src/common/base-store.ts +++ b/src/common/base-store.ts @@ -90,13 +90,19 @@ export class BaseStore extends Singleton { if (ipcRenderer) { const callback = (event: IpcRendererEvent, model: T) => { logger.silly(`[STORE]: SYNC ${this.name} from main`, { model }); - this.onSync(model); + this.onSyncFromMain(model); }; ipcRenderer.on(this.syncChannel, callback); this.syncDisposers.push(() => ipcRenderer.off(this.syncChannel, callback)); } } + protected onSyncFromMain(model: T) { + this.applyWithoutSync(() => { + this.onSync(model) + }) + } + unregisterIpcListener() { ipcRenderer.removeAllListeners(this.syncChannel) } @@ -116,11 +122,9 @@ export class BaseStore extends Singleton { protected onSync(model: T) { // todo: use "resourceVersion" if merge required (to avoid equality checks => better performance) - this.applyWithoutSync(() => { - if (!isEqual(this.toJSON(), model)) { - this.fromStore(model); - } - }) + if (!isEqual(this.toJSON(), model)) { + this.fromStore(model); + } } protected async onModelChange(model: T) {