bug for auto update is fixed
This commit is contained in:
parent
dbc54f8287
commit
18e1a35867
|
@ -45,7 +45,10 @@ import {
|
||||||
NotificationType,
|
NotificationType,
|
||||||
NativePathName
|
NativePathName
|
||||||
} from '@ucap-webmessenger/native';
|
} from '@ucap-webmessenger/native';
|
||||||
import { ElectronAppChannel } from '@ucap-webmessenger/electron-core';
|
import {
|
||||||
|
ElectronAppChannel,
|
||||||
|
ElectronBrowserWindowChannel
|
||||||
|
} from '@ucap-webmessenger/electron-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
autoUpdater,
|
autoUpdater,
|
||||||
|
@ -297,6 +300,10 @@ app.on(ElectronAppChannel.Ready, () => {
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
onReady: () => {},
|
onReady: () => {},
|
||||||
onAcceptUpdate: () => {
|
onAcceptUpdate: () => {
|
||||||
|
if (!!autoUpdaterCancellationToken) {
|
||||||
|
log.info('downloadUpdate already');
|
||||||
|
return;
|
||||||
|
}
|
||||||
log.info('OnAcceptUpdate');
|
log.info('OnAcceptUpdate');
|
||||||
autoUpdaterCancellationToken = new CancellationToken();
|
autoUpdaterCancellationToken = new CancellationToken();
|
||||||
autoUpdater.downloadUpdate(autoUpdaterCancellationToken);
|
autoUpdater.downloadUpdate(autoUpdaterCancellationToken);
|
||||||
|
@ -368,10 +375,15 @@ ipcMain.on(UpdaterChannel.Apply, (event: IpcMainEvent, ...args: any[]) => {
|
||||||
|
|
||||||
if (semver.lt(app.getVersion(), ver)) {
|
if (semver.lt(app.getVersion(), ver)) {
|
||||||
updateCheckResult = undefined;
|
updateCheckResult = undefined;
|
||||||
autoUpdater.checkForUpdatesAndNotify().then(r => {
|
autoUpdater
|
||||||
log.debug('checkForUpdatesAndNotify.then');
|
.checkForUpdatesAndNotify()
|
||||||
updateCheckResult = r;
|
.then(r => {
|
||||||
});
|
updateCheckResult = r;
|
||||||
|
})
|
||||||
|
.catch(reason => {
|
||||||
|
log.error(reason);
|
||||||
|
})
|
||||||
|
.finally(() => {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -796,16 +808,17 @@ autoUpdater.on('update-downloaded', info => {
|
||||||
|
|
||||||
updateWindowService.setDownloadComplete();
|
updateWindowService.setDownloadComplete();
|
||||||
|
|
||||||
app.removeAllListeners('window-all-closed');
|
app.removeAllListeners(ElectronAppChannel.WindowAllClosed);
|
||||||
const browserWindows = BrowserWindow.getAllWindows();
|
const browserWindows = BrowserWindow.getAllWindows();
|
||||||
|
|
||||||
// https://github.com/electron-userland/electron-builder/issues/1604#issuecomment-372091881
|
// https://github.com/electron-userland/electron-builder/issues/1604#issuecomment-372091881
|
||||||
browserWindows.forEach(browserWindow => {
|
browserWindows.forEach(browserWindow => {
|
||||||
browserWindow.removeAllListeners('close');
|
browserWindow.removeAllListeners(ElectronBrowserWindowChannel.Close);
|
||||||
browserWindow.removeAllListeners('closed');
|
browserWindow.removeAllListeners(ElectronBrowserWindowChannel.Closed);
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
updateWindowService.close();
|
||||||
autoUpdater.quitAndInstall(true, true);
|
autoUpdater.quitAndInstall(true, true);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
|
|
|
@ -466,11 +466,8 @@
|
||||||
|
|
||||||
<mat-menu #informationMenu="matMenu">
|
<mat-menu #informationMenu="matMenu">
|
||||||
<ng-template matMenuContent>
|
<ng-template matMenuContent>
|
||||||
<div
|
<div class="version-info-container menu-item">
|
||||||
class="version-info-container menu-item"
|
<div class="version-info-now" (click)="$event.stopPropagation()">
|
||||||
(click)="$event.stopPropagation()"
|
|
||||||
>
|
|
||||||
<div class="version-info-now">
|
|
||||||
<span class="version-info-item">
|
<span class="version-info-item">
|
||||||
{{ 'information.installedVersion' | translate }}:<span
|
{{ 'information.installedVersion' | translate }}:<span
|
||||||
class="info-content"
|
class="info-content"
|
||||||
|
@ -493,7 +490,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="!checkingUpdateIsProcessing" style="display: flex;">
|
<div *ngIf="!checkingUpdateIsProcessing" style="display: flex;">
|
||||||
<span class="version-info-item">
|
<span class="version-info-item" (click)="$event.stopPropagation()">
|
||||||
{{ 'information.latestVersion' | translate }}:<span
|
{{ 'information.latestVersion' | translate }}:<span
|
||||||
class="info-content"
|
class="info-content"
|
||||||
>{{ checkingUpdateAppVersion }}</span
|
>{{ checkingUpdateAppVersion }}</span
|
||||||
|
|
|
@ -562,9 +562,9 @@ export class TopBarComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
onClickApplyUpdate(event: Event) {
|
onClickApplyUpdate(event: Event) {
|
||||||
// this.profileMenuTrigger.closeMenu();
|
// this.profileMenuTrigger.closeMenu();
|
||||||
setTimeout(() => {
|
this.store.dispatch(
|
||||||
this.nativeService.checkForUpdates(this.checkingUpdateAppVersion);
|
UpdateStore.applyUpdate({ currentVersion: this.checkingUpdateAppVersion })
|
||||||
}, 1000);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onIntegratedSearch(keyword: string) {
|
onIntegratedSearch(keyword: string) {
|
||||||
|
|
|
@ -2,10 +2,15 @@ import { createAction, props } from '@ngrx/store';
|
||||||
import { UpdateInfo } from '@ucap-webmessenger/native';
|
import { UpdateInfo } from '@ucap-webmessenger/native';
|
||||||
|
|
||||||
export const existInstantUpdate = createAction(
|
export const existInstantUpdate = createAction(
|
||||||
'[Setting::Update] existInstantUpdate',
|
'[Setting::Update] Exist Instant Update',
|
||||||
props<{ updateInfo: UpdateInfo }>()
|
props<{ updateInfo: UpdateInfo }>()
|
||||||
);
|
);
|
||||||
|
|
||||||
export const applyInstantUpdate = createAction(
|
export const applyUpdate = createAction(
|
||||||
'[Setting::Update] applyInstantUpdate'
|
'[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 { Injectable, Inject } from '@angular/core';
|
||||||
import { createEffect, Actions, ofType } from '@ngrx/effects';
|
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 { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
|
||||||
import { tap } from 'rxjs/operators';
|
import { tap, map } from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class Effects {
|
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(
|
applyInstantUpdate$ = createEffect(
|
||||||
() => {
|
() => {
|
||||||
return this.actions$.pipe(
|
return this.actions$.pipe(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user