Main: Move window bounds persistence logic over to the main process

This commit is contained in:
Svallinn 2021-07-03 03:43:49 +01:00
parent 718f9450d6
commit 2ce3110041
No known key found for this signature in database
GPG Key ID: 09FB527F34037CCA
2 changed files with 17 additions and 23 deletions

View File

@ -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)

View File

@ -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'
]),