From 834645025cb83e95ed3de5c04076d6cf534bb5c6 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sat, 16 May 2020 16:49:49 +0200 Subject: [PATCH] fix(app): ensure app restarts during autoupdate fix #3198 --- electron/updater.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/electron/updater.js b/electron/updater.js index 2dc301eabba..d687e72d048 100644 --- a/electron/updater.js +++ b/electron/updater.js @@ -22,20 +22,25 @@ class ZapUpdater { this.configure({ ...config.autoupdate, ...options }) - autoUpdater.on('update-downloaded', () => { - const opt = { - type: 'question', - buttons: ['Install', 'Later'], - title: 'Update available', - message: 'An update is available. Restart the app and install?', + autoUpdater.on('update-downloaded', async info => { + updaterLog.info('Downloaded update: %o', info) + const dialogOpts = { + type: 'info', + buttons: ['Restart', 'Later'], + title: 'Application Update', + message: 'A new version has been downloaded. Restart the application to apply the updates.', } - dialog.showMessageBox(this.mainWindow, opt, async choice => { - if (choice !== 0) { - return - } - await delay(100) + const returnValue = await dialog.showMessageBox(this.mainWindow, dialogOpts) + if (returnValue.response === 0) { + await delay(500) + mainWindow.forceClose = true autoUpdater.quitAndInstall() - }) + } + }) + + autoUpdater.on('error', message => { + updaterLog.warn('There was a problem updating the application: %s', message) + dialog.showErrorBox('There was a problem updating the application', message) }) // Enable updates if needed.