MacOS: Closing with red button won't open window again through tray icon (#40)

* Fixed issue on MacOS where closing BW via the red button then reopening using tray icon wouldn't work

* Added MacOS only condition to the window recreation of the toggleWindow method. Made createWindow public in WindowMain.
This commit is contained in:
Michael Honan 2019-05-16 12:44:25 +10:00 committed by Kyle Spearrin
parent 741e060d99
commit 1bcd430884
2 changed files with 13 additions and 8 deletions

View File

@ -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();
}
}
}

View File

@ -81,7 +81,7 @@ export class WindowMain {
});
}
private async createWindow() {
async createWindow(): Promise<void> {
this.windowStates[Keys.mainWindowSize] = await this.getWindowState(Keys.mainWindowSize, this.defaultWidth,
this.defaultHeight);