bug for auto update is fixed
This commit is contained in:
parent
dbc54f8287
commit
18e1a35867
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -466,11 +466,8 @@
|
|||
|
||||
<mat-menu #informationMenu="matMenu">
|
||||
<ng-template matMenuContent>
|
||||
<div
|
||||
class="version-info-container menu-item"
|
||||
(click)="$event.stopPropagation()"
|
||||
>
|
||||
<div class="version-info-now">
|
||||
<div class="version-info-container menu-item">
|
||||
<div class="version-info-now" (click)="$event.stopPropagation()">
|
||||
<span class="version-info-item">
|
||||
{{ 'information.installedVersion' | translate }}:<span
|
||||
class="info-content"
|
||||
|
@ -493,7 +490,7 @@
|
|||
</div>
|
||||
|
||||
<div *ngIf="!checkingUpdateIsProcessing" style="display: flex;">
|
||||
<span class="version-info-item">
|
||||
<span class="version-info-item" (click)="$event.stopPropagation()">
|
||||
{{ 'information.latestVersion' | translate }}:<span
|
||||
class="info-content"
|
||||
>{{ checkingUpdateAppVersion }}</span
|
||||
|
|
|
@ -562,9 +562,9 @@ export class TopBarComponent implements OnInit, OnDestroy {
|
|||
|
||||
onClickApplyUpdate(event: Event) {
|
||||
// this.profileMenuTrigger.closeMenu();
|
||||
setTimeout(() => {
|
||||
this.nativeService.checkForUpdates(this.checkingUpdateAppVersion);
|
||||
}, 1000);
|
||||
this.store.dispatch(
|
||||
UpdateStore.applyUpdate({ currentVersion: this.checkingUpdateAppVersion })
|
||||
);
|
||||
}
|
||||
|
||||
onIntegratedSearch(keyword: string) {
|
||||
|
|
|
@ -2,10 +2,15 @@ import { createAction, props } from '@ngrx/store';
|
|||
import { UpdateInfo } from '@ucap-webmessenger/native';
|
||||
|
||||
export const existInstantUpdate = createAction(
|
||||
'[Setting::Update] existInstantUpdate',
|
||||
'[Setting::Update] Exist Instant Update',
|
||||
props<{ updateInfo: UpdateInfo }>()
|
||||
);
|
||||
|
||||
export const applyInstantUpdate = createAction(
|
||||
'[Setting::Update] applyInstantUpdate'
|
||||
export const applyUpdate = createAction(
|
||||
'[Setting::Update] Apply Update',
|
||||
props<{ currentVersion: string }>()
|
||||
);
|
||||
|
||||
export const applyInstantUpdate = createAction(
|
||||
'[Setting::Update] Apply Instant Update'
|
||||
);
|
||||
|
|
|
@ -1,11 +1,24 @@
|
|||
import { Injectable, Inject } from '@angular/core';
|
||||
import { createEffect, Actions, ofType } from '@ngrx/effects';
|
||||
import { applyInstantUpdate } from './actions';
|
||||
import { applyInstantUpdate, applyUpdate } from './actions';
|
||||
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { tap, map } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
applyUpdate$ = createEffect(
|
||||
() => {
|
||||
return this.actions$.pipe(
|
||||
ofType(applyUpdate),
|
||||
map(action => action.currentVersion),
|
||||
tap(currentVersion => {
|
||||
this.nativeService.checkForUpdates(currentVersion);
|
||||
})
|
||||
);
|
||||
},
|
||||
{ dispatch: false }
|
||||
);
|
||||
|
||||
applyInstantUpdate$ = createEffect(
|
||||
() => {
|
||||
return this.actions$.pipe(
|
||||
|
|
Loading…
Reference in New Issue
Block a user