diff --git a/src/main/index.js b/src/main/index.js index 910d205c..04675674 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -294,33 +294,18 @@ function runApp() { } // Save closing window bounds & maximized status - ipcMain.on('setBounds', (_e, data) => { + ipcMain.on('setBounds', (event) => { const value = { ...mainWindow.getNormalBounds(), maximized: mainWindow.isMaximized() } - settingsDb.findOne({ - _id: 'bounds' - }, function (err, doc) { - if (err) { - return - } - if (doc !== null) { - settingsDb.update({ - _id: 'bounds' - }, { - $set: { - value - } - }, {}) - } else { - settingsDb.insert({ - _id: 'bounds', - value - }) - } - }) + settingsDb.update( + { _id: 'bounds' }, + { _id: 'bounds', value }, + { upsert: true }, + () => { event.returnValue = 0 } + ) }) ipcMain.on('appReady', () => { diff --git a/src/renderer/App.js b/src/renderer/App.js index fed5bf3a..1880c59d 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -403,8 +403,8 @@ export default Vue.extend({ }, setBoundsOnClose: function () { - window.onbeforeunload = (e) => { - ipcRenderer.send('setBounds') + window.onbeforeunload = () => { + ipcRenderer.sendSync('setBounds') } },