diff --git a/src/main/models/settings.ts b/src/main/models/settings.ts index 9f9bad5f9..d0a62f003 100644 --- a/src/main/models/settings.ts +++ b/src/main/models/settings.ts @@ -73,15 +73,18 @@ export class Settings extends EventEmitter { }; public update = () => { + let themeSource = 'system'; + if (this.object.themeAuto) { this.object.theme = nativeTheme.shouldUseDarkColors ? 'wexond-dark' : 'wexond-light'; - - nativeTheme.themeSource = 'system'; } else { - nativeTheme.themeSource = - this.object.theme === 'wexond-dark' ? 'dark' : 'light'; + themeSource = this.object.theme === 'wexond-dark' ? 'dark' : 'light'; + } + + if (themeSource !== nativeTheme.themeSource) { + nativeTheme.themeSource = themeSource as any; } Application.instance.dialogs.sendToAll('update-settings', this.object); diff --git a/src/main/services/dialogs-service.ts b/src/main/services/dialogs-service.ts index e7f5ce057..e9660daaf 100644 --- a/src/main/services/dialogs-service.ts +++ b/src/main/services/dialogs-service.ts @@ -305,7 +305,9 @@ export class DialogsService { }; public sendToAll = (channel: string, ...args: any[]) => { - this.getBrowserViews().forEach((x) => x.webContents.send(channel, ...args)); + this.getBrowserViews().forEach( + (x) => !x.isDestroyed() && x.webContents.send(channel, ...args), + ); }; public get(name: string) { diff --git a/src/main/view.ts b/src/main/view.ts index e96378c70..cb4f96239 100644 --- a/src/main/view.ts +++ b/src/main/view.ts @@ -200,7 +200,7 @@ export class View { this.emitEvent('favicon-updated', fav); } catch (e) { this.favicon = ''; - console.error(e); + // console.error(e); } }, );