diff --git a/src/electron/tray.main.ts b/src/electron/tray.main.ts index 287d233303..7645cf6af7 100644 --- a/src/electron/tray.main.ts +++ b/src/electron/tray.main.ts @@ -121,14 +121,19 @@ export class TrayMain { } private toggleWindow() { - if (this.windowMain.win == null) { - return; - } - - if (this.windowMain.win.isVisible()) { - this.windowMain.win.hide(); + if (this.windowMain.win === null) { + if (process.platform === 'darwin') { + // On MacOS, closing the window via the red button destroys the BrowserWindow instance. + this.windowMain.createWindow().then(() => { + this.windowMain.win.show(); + }); + } } else { - this.windowMain.win.show(); + if (this.windowMain.win.isVisible()) { + this.windowMain.win.hide(); + } else { + this.windowMain.win.show(); + } } } diff --git a/src/electron/window.main.ts b/src/electron/window.main.ts index cb6d5d70df..865ea81368 100644 --- a/src/electron/window.main.ts +++ b/src/electron/window.main.ts @@ -81,7 +81,7 @@ export class WindowMain { }); } - private async createWindow() { + async createWindow(): Promise { this.windowStates[Keys.mainWindowSize] = await this.getWindowState(Keys.mainWindowSize, this.defaultWidth, this.defaultHeight);