diff --git a/packages/uhk-agent/src/services/app-update.service.ts b/packages/uhk-agent/src/services/app-update.service.ts index 18f7514d72a..7aeeb2a8c22 100644 --- a/packages/uhk-agent/src/services/app-update.service.ts +++ b/packages/uhk-agent/src/services/app-update.service.ts @@ -46,14 +46,8 @@ export class AppUpdateService extends MainServiceBase { }); autoUpdater.on('update-available', (info: UpdateInfo) => { - this.logService.misc('[AppUpdateService] update available. Downloading started'); - autoUpdater.downloadUpdate() - .then(() => { - this.sendIpcToWindow(IpcEvents.autoUpdater.updateAvailable, info); - }) - .catch((error) => { - this.logService.error('[AppUpdateService] Error when reporting update available: ', error); - }); + this.logService.misc('[AppUpdateService] update available'); + this.sendIpcToWindow(IpcEvents.autoUpdater.updateAvailable, info); }); autoUpdater.on('update-not-available', (info: UpdateInfo) => { @@ -93,13 +87,18 @@ export class AppUpdateService extends MainServiceBase { return autoUpdater.quitAndInstall(true, true); }); + ipcMain.on(IpcEvents.autoUpdater.downloadUpdate, () => { + this.logService.misc('[AppUpdateService] download update from renderer process'); + this.downloadUpdate(); + }); + ipcMain.on(IpcEvents.app.appStarted, () => { this.logService.misc('[AppUpdateService] app started'); this.checkForUpdateAtStartup() .then((checkForUpdate) => { if (checkForUpdate) { this.sendAutoUpdateNotification = false; - this.logService.misc('[AppUpdateService] app started. Automatically check for update.'); + this.logService.misc('[AppUpdateService] app started. Check for new Agent version on startup.'); this.checkForUpdate(); } }) @@ -136,6 +135,13 @@ export class AppUpdateService extends MainServiceBase { }); } + private downloadUpdate(): void { + autoUpdater.downloadUpdate() + .catch((error) => { + this.logService.error('[AppUpdateService] Error when downloading update: ', error); + }); + } + private async checkForUpdateAtStartup() { const { checkForUpdateOnStartUp = true } = await this.getApplicationSettings(); diff --git a/packages/uhk-common/src/util/ipcEvents.ts b/packages/uhk-common/src/util/ipcEvents.ts index 0c8b05b524e..3d77152de6b 100644 --- a/packages/uhk-common/src/util/ipcEvents.ts +++ b/packages/uhk-common/src/util/ipcEvents.ts @@ -17,6 +17,7 @@ export class AutoUpdate { public static readonly autoUpdateDownloaded = 'update-downloaded'; public static readonly autoUpdateDownloadProgress = 'auto-update-download-progress'; public static readonly updateAndRestart = 'update-and-restart'; + public static readonly downloadUpdate = 'download-update'; public static readonly checkForUpdate = 'check-for-update'; public static readonly checkForUpdateNotAvailable = 'check-for-update-not-available'; } diff --git a/packages/uhk-web/src/app/app.component.html b/packages/uhk-web/src/app/app.component.html index ba2def56b50..1d74eec62c2 100644 --- a/packages/uhk-web/src/app/app.component.html +++ b/packages/uhk-web/src/app/app.component.html @@ -1,7 +1,6 @@