check tabs before closing the window (fixes #520)

This commit is contained in:
Eugene Pankov
2018-11-22 17:51:12 +01:00
parent 12d1fb9334
commit eb81b9fd01
6 changed files with 40 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ export class Window {
private window: BrowserWindow
private windowConfig: ElectronConfig
private windowBounds: Rectangle
private closing = false
get visible$ (): Observable<boolean> { return this.visible }
@@ -145,7 +146,12 @@ export class Window {
this.window.on('enter-full-screen', () => this.window.webContents.send('host:window-enter-full-screen'))
this.window.on('leave-full-screen', () => this.window.webContents.send('host:window-leave-full-screen'))
this.window.on('close', () => {
this.window.on('close', event => {
if (!this.closing) {
event.preventDefault()
this.window.webContents.send('host:window-close-request')
return
}
this.windowConfig.set('windowBoundaries', this.windowBounds)
this.windowConfig.set('maximized', this.window.isMaximized())
})
@@ -244,6 +250,11 @@ export class Window {
this.window.moveTop()
})
ipcMain.on('window-close', () => {
this.closing = true
this.window.close()
})
this.window.webContents.on('new-window', event => event.preventDefault())
}