Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(app): ensure app restarts during autoupdate
Browse files Browse the repository at this point in the history
fix #3198
  • Loading branch information
mrfelton committed May 16, 2020
1 parent 8be6cf0 commit 8346450
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions electron/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8346450

Please sign in to comment.