mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
Check for updates always if user requests it, add comments
This commit is contained in:
parent
bc26d643ca
commit
2f2bbd0a27
@ -92,20 +92,25 @@ export class Updater {
|
|||||||
async checkForUpdates(userInput: boolean) {
|
async checkForUpdates(userInput: boolean) {
|
||||||
const autoUpdateOpts = (await services.FileService.GetSettingsConfig()).autoupdate;
|
const autoUpdateOpts = (await services.FileService.GetSettingsConfig()).autoupdate;
|
||||||
|
|
||||||
if (!autoUpdateOpts.enabled) {
|
// If there's an active update check interval, check that the user still has auto update checks enabled. If not, remove the interval.
|
||||||
|
if (this.interval && !autoUpdateOpts.enabled) {
|
||||||
console.log("Auto update is disabled in settings. Removing the auto update interval.");
|
console.log("Auto update is disabled in settings. Removing the auto update interval.");
|
||||||
clearInterval(this.interval);
|
clearInterval(this.interval);
|
||||||
this.interval = null;
|
this.interval = null;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
|
// Run an update check always if the user requests it, otherwise only if there's an active update check interval and enough time has elapsed.
|
||||||
if (
|
if (
|
||||||
userInput ||
|
userInput ||
|
||||||
!this.lastUpdateCheck ||
|
(this.interval &&
|
||||||
Math.abs(now.getTime() - this.lastUpdateCheck.getTime()) > autoUpdateOpts.intervalms
|
(!this.lastUpdateCheck ||
|
||||||
|
Math.abs(now.getTime() - this.lastUpdateCheck.getTime()) > autoUpdateOpts.intervalms))
|
||||||
) {
|
) {
|
||||||
const result = await autoUpdater.checkForUpdates();
|
const result = await autoUpdater.checkForUpdates();
|
||||||
console.log("check for updates result:", result.updateInfo.version, result);
|
|
||||||
|
// If the user requested this check and we do not have an available update, let them know with a popup dialog. No need to tell them if there is an update, because we show a banner once the update is ready to install.
|
||||||
if (userInput && !result.downloadPromise) {
|
if (userInput && !result.downloadPromise) {
|
||||||
const dialogOpts: Electron.MessageBoxOptions = {
|
const dialogOpts: Electron.MessageBoxOptions = {
|
||||||
type: "info",
|
type: "info",
|
||||||
@ -113,6 +118,8 @@ export class Updater {
|
|||||||
};
|
};
|
||||||
electron.dialog.showMessageBox(electron.BrowserWindow.getFocusedWindow(), dialogOpts);
|
electron.dialog.showMessageBox(electron.BrowserWindow.getFocusedWindow(), dialogOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only update the last check time if this is an automatic check. This ensures the interval remains consistent.
|
||||||
if (!userInput) this.lastUpdateCheck = now;
|
if (!userInput) this.lastUpdateCheck = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user