From 5f229048bec421891c69631da570757752b06ca0 Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Tue, 6 Aug 2024 16:13:14 -0700 Subject: [PATCH] restart interval in checkForUpdates if update setting changes --- emain/updater.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/emain/updater.ts b/emain/updater.ts index 828c17b3f..b2ea1f2de 100644 --- a/emain/updater.ts +++ b/emain/updater.ts @@ -75,14 +75,15 @@ export class Updater { /** * Starts the auto update check interval. + * @param [runCheckNow=true] Determines whether the update check should run immediately. Defaults to true. * @returns The timeout object for the auto update checker. */ - startAutoUpdateInterval(): NodeJS.Timeout { + startInterval(runCheckNow = true): NodeJS.Timeout { // check for updates right away and keep checking later - this.checkForUpdates(false); + if (runCheckNow) this.checkForUpdates(false); return setInterval(() => { this.checkForUpdates(false); - }, 600000); // intervals are unreliable when an app is suspended so we will check every 10 mins if an hour has passed. + }, 600000); // intervals are unreliable when an app is suspended so we will check every 10 mins if the interval has passed. } /** @@ -97,6 +98,8 @@ export class Updater { console.log("Auto update is disabled in settings. Removing the auto update interval."); clearInterval(this.interval); this.interval = null; + } else if (!this.interval && autoUpdateOpts.enabled) { + this.startInterval(false); } const now = new Date(); @@ -187,7 +190,7 @@ export async function configureAutoUpdater() { if (autoUpdateEnabled && updater?.interval == null) { try { console.log("configuring auto update interval"); - updater?.startAutoUpdateInterval(); + updater?.startInterval(); } catch (e) { console.log("error configuring auto update interval", e.toString()); }