From c28b2193626dd7981e7060d5e9607571c449aaad Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Thu, 23 Dec 2021 16:49:12 -0500 Subject: [PATCH] [MM-40635] Fix notifications and badges broken during test changes (#1934) --- src/main/appState.ts | 2 +- src/main/views/MattermostView.ts | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/appState.ts b/src/main/appState.ts index 778ef922..3996a7b8 100644 --- a/src/main/appState.ts +++ b/src/main/appState.ts @@ -104,7 +104,7 @@ const anyExpired = () => { }; // add any other event emitter methods if needed -export const on = status.emitter.on; +export const on = status.emitter.on.bind(status.emitter); const setSessionExpired = (serverName: string, expired: boolean) => { const isExpired = Boolean(expired); diff --git a/src/main/views/MattermostView.ts b/src/main/views/MattermostView.ts index 9e10b721..6feb84cc 100644 --- a/src/main/views/MattermostView.ts +++ b/src/main/views/MattermostView.ts @@ -101,13 +101,17 @@ export class MattermostView extends EventEmitter { } this.view.webContents.on('did-finish-load', () => { - if (!this.view.webContents.isLoading()) { - try { - this.view.webContents.send(SET_VIEW_OPTIONS, this.tab.name, this.tab.shouldNotify); - } catch (e) { - log.error('failed to send view options to view', this.tab.name); + // wait for screen to truly finish loading before sending the message down + const timeout = setInterval(() => { + if (!this.view.webContents.isLoading()) { + try { + this.view.webContents.send(SET_VIEW_OPTIONS, this.tab.name, this.tab.shouldNotify); + clearTimeout(timeout); + } catch (e) { + log.error('failed to send view options to view', this.tab.name); + } } - } + }, 100); }); this.contextMenu = new ContextMenu({}, this.view);