Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Commit

Permalink
fix: process hang due to theme source endless loop (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
sentialx authored May 6, 2020
1 parent f8d142f commit c89363e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/main/models/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/main/services/dialogs-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class View {
this.emitEvent('favicon-updated', fav);
} catch (e) {
this.favicon = '';
console.error(e);
// console.error(e);
}
},
);
Expand Down

0 comments on commit c89363e

Please sign in to comment.