From 18e1a35867f1fde5b0cdf551c3b611d66c588a24 Mon Sep 17 00:00:00 2001 From: richard-loafle <44828666+richard-loafle@users.noreply.github.com> Date: Mon, 10 Feb 2020 13:45:02 +0900 Subject: [PATCH] bug for auto update is fixed --- .../ucap-webmessenger-electron/src/index.ts | 29 ++++++++++++++----- .../native/components/top-bar.component.html | 9 ++---- .../native/components/top-bar.component.ts | 6 ++-- .../src/app/store/setting/update/actions.ts | 11 +++++-- .../src/app/store/setting/update/effects.ts | 17 +++++++++-- 5 files changed, 50 insertions(+), 22 deletions(-) diff --git a/electron-projects/ucap-webmessenger-electron/src/index.ts b/electron-projects/ucap-webmessenger-electron/src/index.ts index 433602d5..1ae23473 100644 --- a/electron-projects/ucap-webmessenger-electron/src/index.ts +++ b/electron-projects/ucap-webmessenger-electron/src/index.ts @@ -45,7 +45,10 @@ import { NotificationType, NativePathName } from '@ucap-webmessenger/native'; -import { ElectronAppChannel } from '@ucap-webmessenger/electron-core'; +import { + ElectronAppChannel, + ElectronBrowserWindowChannel +} from '@ucap-webmessenger/electron-core'; import { autoUpdater, @@ -297,6 +300,10 @@ app.on(ElectronAppChannel.Ready, () => { maximizable: false, onReady: () => {}, onAcceptUpdate: () => { + if (!!autoUpdaterCancellationToken) { + log.info('downloadUpdate already'); + return; + } log.info('OnAcceptUpdate'); autoUpdaterCancellationToken = new CancellationToken(); autoUpdater.downloadUpdate(autoUpdaterCancellationToken); @@ -368,10 +375,15 @@ ipcMain.on(UpdaterChannel.Apply, (event: IpcMainEvent, ...args: any[]) => { if (semver.lt(app.getVersion(), ver)) { updateCheckResult = undefined; - autoUpdater.checkForUpdatesAndNotify().then(r => { - log.debug('checkForUpdatesAndNotify.then'); - updateCheckResult = r; - }); + autoUpdater + .checkForUpdatesAndNotify() + .then(r => { + updateCheckResult = r; + }) + .catch(reason => { + log.error(reason); + }) + .finally(() => {}); } }); @@ -796,16 +808,17 @@ autoUpdater.on('update-downloaded', info => { updateWindowService.setDownloadComplete(); - app.removeAllListeners('window-all-closed'); + app.removeAllListeners(ElectronAppChannel.WindowAllClosed); const browserWindows = BrowserWindow.getAllWindows(); // https://github.com/electron-userland/electron-builder/issues/1604#issuecomment-372091881 browserWindows.forEach(browserWindow => { - browserWindow.removeAllListeners('close'); - browserWindow.removeAllListeners('closed'); + browserWindow.removeAllListeners(ElectronBrowserWindowChannel.Close); + browserWindow.removeAllListeners(ElectronBrowserWindowChannel.Closed); }); setTimeout(() => { + updateWindowService.close(); autoUpdater.quitAndInstall(true, true); }, 2000); }); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html index c72a8dc9..2d939702 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html @@ -466,11 +466,8 @@ -