add debug logs and better checks
This commit is contained in:
parent
024707c5b4
commit
313a5d0c1b
|
@ -1,4 +1,4 @@
|
|||
import { BrowserWindow, Tray } from 'electron';
|
||||
import { app, BrowserWindow, Tray } from 'electron';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
import log from 'electron-log';
|
||||
import { setIsAppQuitting, setIsUpdateAvailable } from '../main';
|
||||
|
@ -15,24 +15,33 @@ class AppUpdater {
|
|||
}
|
||||
|
||||
async checkForUpdate(tray: Tray, mainWindow: BrowserWindow) {
|
||||
log.debug('checkForUpdate');
|
||||
const updateCheckResult = await autoUpdater.checkForUpdatesAndNotify();
|
||||
log.info(updateCheckResult);
|
||||
log.debug(updateCheckResult);
|
||||
if (
|
||||
semVerCmp(
|
||||
updateCheckResult.updateInfo.version,
|
||||
LATEST_SUPPORTED_AUTO_UPDATE_VERSION
|
||||
) > 0
|
||||
semVerCmp(updateCheckResult.updateInfo.version, app.getVersion()) >
|
||||
0
|
||||
) {
|
||||
this.updateDownloaded = false;
|
||||
this.showUpdateDialog(mainWindow);
|
||||
} else {
|
||||
autoUpdater.downloadUpdate();
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
this.updateDownloaded = true;
|
||||
log.debug('update available');
|
||||
if (
|
||||
semVerCmp(
|
||||
updateCheckResult.updateInfo.version,
|
||||
LATEST_SUPPORTED_AUTO_UPDATE_VERSION
|
||||
) > 0
|
||||
) {
|
||||
log.debug('update not supported');
|
||||
this.updateDownloaded = false;
|
||||
this.showUpdateDialog(mainWindow);
|
||||
setIsUpdateAvailable(true);
|
||||
tray.setContextMenu(buildContextMenu(mainWindow));
|
||||
});
|
||||
} else {
|
||||
log.debug('update supported');
|
||||
autoUpdater.downloadUpdate();
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
this.updateDownloaded = true;
|
||||
this.showUpdateDialog(mainWindow);
|
||||
});
|
||||
}
|
||||
setIsUpdateAvailable(true);
|
||||
tray.setContextMenu(buildContextMenu(mainWindow));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue