Main: Move window bounds persistence logic over to the main process
This commit is contained in:
parent
718f9450d6
commit
2ce3110041
|
@ -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)
|
||||
|
|
|
@ -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'
|
||||
]),
|
||||
|
|
Loading…
Reference in New Issue