diff --git a/browser/main/index.js b/browser/main/index.js index f25f05be..404b38e1 100644 --- a/browser/main/index.js +++ b/browser/main/index.js @@ -117,8 +117,9 @@ function downloadUpdate() { }) if (index === 0) { - ipcRenderer.send('update-app-confirm') + ipcRenderer.send('update-download-confirm') } else if (index === 1) { + ipcRenderer.send('update-cancel') ConfigManager.set({ autoUpdateEnabled: false }) } } diff --git a/lib/main-app.js b/lib/main-app.js index 19d3f91d..c0040084 100644 --- a/lib/main-app.js +++ b/lib/main-app.js @@ -26,6 +26,7 @@ if (!singleInstance) { } var isUpdateReady = false +let updateFound = false var ghReleasesOpts = { repo: 'BoostIO/boost-releases', @@ -37,15 +38,17 @@ const updater = new GhReleases(ghReleasesOpts) // Check for updates // `status` returns true if there is a new update available function checkUpdate(manualTriggered = false) { - // if (!isPackaged) { - // Prevents app from attempting to update when in dev mode. - // console.log('Updates are disabled in Development mode, see main-app.js') - // return true - // } + if (!isPackaged) { + // Prevents app from attempting to update when in dev mode. + console.log('Updates are disabled in Development mode, see main-app.js') + return true + } + if (!electronConfig.get('autoUpdateEnabled', true) && !manualTriggered) return - // if (process.platform === 'linux' || isUpdateReady) { - // return true - // } + if (process.platform === 'linux' || isUpdateReady || updateFound) { + console.log('READY|FOUND', isUpdateReady, updateFound) + return true + } updater.check((err, status) => { if (err) { @@ -59,7 +62,7 @@ function checkUpdate(manualTriggered = false) { } if (status) { mainWindow.webContents.send('update-found', 'Update available!') - updater.download() + updateFound = true } }) } @@ -68,6 +71,7 @@ updater.on('update-downloaded', info => { if (mainWindow != null) { mainWindow.webContents.send('update-ready', 'Update available!') isUpdateReady = true + updateFound = false } }) @@ -82,6 +86,14 @@ ipc.on('update-app-confirm', function(event, msg) { } }) +ipc.on('update-cancel', () => { + updateFound = false +}) + +ipc.on('update-download-confirm', () => { + updater.download() +}) + app.on('window-all-closed', function() { app.quit() })