bug of updater is fixed

This commit is contained in:
병준 박 2019-12-16 02:33:40 +09:00
parent e4a42d0dcc
commit c37f439fb0
5 changed files with 26 additions and 13 deletions

View File

@ -268,11 +268,6 @@ app.on(ElectronAppChannel.Ready, () => {
}
});
updateWindowService.options.webPreferences.preload = path.join(
__dirname,
'resources/update-window/preload.js'
);
updateWindowService.templatePath = path.join(
__dirname,
'resources/update-window/template.html'
@ -319,12 +314,28 @@ function onDidLoad(fn: OnDidLoadFn) {
}
ipcMain.on(UpdaterChannel.Check, (event: IpcMainEvent, ...args: any[]) => {
// if (__DEV__) {
// event.returnValue = false;
// return;
// }
const ver = args[0];
if (semver.lt(app.getVersion(), ver)) {
autoUpdater.checkForUpdatesAndNotify();
return true;
autoUpdater
.checkForUpdatesAndNotify()
.then(result => {
if (!result) {
event.returnValue = false;
} else {
event.returnValue = true;
}
})
.catch(reason => {
event.returnValue = false;
});
} else {
return false;
event.returnValue = false;
}
});

View File

@ -119,7 +119,7 @@ export class Effects {
params =>
new Observable<void>(subscriber => {
this.nativeService
.checkForUpdates()
.checkForUpdates(params.login2Response.version)
.then((update: boolean) => {
if (!update) {
this.appAuthenticationService.login(

View File

@ -70,7 +70,7 @@ export class BrowserNativeService extends NativeService {
}
closeAllNotify(): void {}
checkForUpdates(): Promise<boolean> {
checkForUpdates(currentVersion: string): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
resolve(false);
});

View File

@ -105,10 +105,12 @@ export class ElectronNativeService implements NativeService {
this.ipcRenderer.send(NotificationChannel.CloseAllNotify);
}
checkForUpdates(): Promise<boolean> {
checkForUpdates(currentVersion: string): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
try {
resolve(this.ipcRenderer.sendSync(UpdaterChannel.Check));
resolve(
this.ipcRenderer.sendSync(UpdaterChannel.Check, currentVersion)
);
} catch (error) {
reject(error);
}

View File

@ -17,7 +17,7 @@ export abstract class NativeService {
abstract notify(noti: NotificationRequest): void;
abstract closeAllNotify(): void;
abstract checkForUpdates(): Promise<boolean>;
abstract checkForUpdates(currentVersion: string): Promise<boolean>;
abstract checkForInstantUpdates(
config: UpdateCheckConfig
): Observable<UpdateInfo>;