Skip to content

A full-featured download manager.

fix: handle auto updater update canceled event

Dr_rOote5eace479d70
diff --git a/src/main/Application.js b/src/main/Application.js
index 8359e6c8..abf9c74c 100644
--- a/src/main/Application.js
+++ b/src/main/Application.js
@@ -663,6 +663,13 @@ export default class Application extends EventEmitter {
win.setProgressBar(0)
})
+ this.updateManager.on('update-cancelled', (event) => {
+ this.menuManager.updateMenuItemEnabledState('app.check-for-updates', true)
+ this.trayManager.updateMenuItemEnabledState('app.check-for-updates', true)
+ const win = this.windowManager.getWindow('index')
+ win.setProgressBar(-1)
+ })
+
this.updateManager.on('will-updated', async (event) => {
this.windowManager.setWillQuit(true)
await this.stopAllSettled()
diff --git a/src/main/core/UpdateManager.js b/src/main/core/UpdateManager.js
index 75dd8ca7..7716f15b 100644
--- a/src/main/core/UpdateManager.js
+++ b/src/main/core/UpdateManager.js
@@ -72,6 +72,8 @@ export default class UpdateManager extends EventEmitter {
}).then(({ response }) => {
if (response === 0) {
this.updater.downloadUpdate()
+ } else {
+ this.emit('update-cancelled', info)
}
})
}