1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-11 00:36:26 +00:00

Fix Cancel update

This commit is contained in:
Gonçalo Santos
2020-05-14 22:02:10 +01:00
committed by Junyoung Choi
parent 553832bdfa
commit 3e405e1abf
2 changed files with 23 additions and 10 deletions

View File

@@ -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 })
}
}

View File

@@ -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()
})