diff --git a/src/main/index.js b/src/main/index.js index fa59908a0..38381e950 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -252,6 +252,23 @@ function runApp() { newWindow.focus() }) + newWindow.once('close', async () => { + if (BrowserWindow.getAllWindows().length !== 1) { + return + } + + const value = { + ...newWindow.getNormalBounds(), + maximized: newWindow.isMaximized() + } + + await settingsDb.update( + { _id: 'bounds' }, + { _id: 'bounds', value }, + { upsert: true } + ) + }) + newWindow.once('closed', () => { const allWindows = BrowserWindow.getAllWindows() if (allWindows.length !== 0 && newWindow === mainWindow) { @@ -264,22 +281,6 @@ function runApp() { }) } - // Save closing window bounds & maximized status - ipcMain.on('setBounds', async (event) => { - const value = { - ...mainWindow.getNormalBounds(), - maximized: mainWindow.isMaximized() - } - - await settingsDb.update( - { _id: 'bounds' }, - { _id: 'bounds', value }, - { upsert: true } - ) - - event.returnValue = 0 - }) - ipcMain.on('appReady', () => { if (startupUrl) { mainWindow.webContents.send('openUrl', startupUrl) diff --git a/src/renderer/App.js b/src/renderer/App.js index e44fdaced..563e5d16e 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -103,7 +103,6 @@ export default Vue.extend({ this.activateKeyboardShortcuts() this.openAllLinksExternally() this.enableOpenUrl() - this.setBoundsOnClose() await this.checkExternalPlayer() } @@ -380,12 +379,6 @@ export default Vue.extend({ ipcRenderer.send('appReady') }, - setBoundsOnClose: function () { - window.onbeforeunload = () => { - ipcRenderer.sendSync('setBounds') - } - }, - ...mapMutations([ 'setInvidiousInstancesList' ]),