提交 3e405e1a 编写于 作者: G Gonçalo Santos 提交者: Junyoung Choi

Fix Cancel update

上级 553832bd
......@@ -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 })
}
}
......
......@@ -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()
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册