diff --git a/desktop/src/auto-update.js b/desktop/src/auto-update.js --- a/desktop/src/auto-update.js +++ b/desktop/src/auto-update.js @@ -11,13 +11,23 @@ // Check for new updates every 10 minutes const updateIntervalMs = 10 * 60_000; + let updateCheckSchedule = null; const scheduleCheckForUpdates = () => { - setTimeout(() => autoUpdater.checkForUpdates(), updateIntervalMs); + if (updateCheckSchedule) { + clearInterval(updateCheckSchedule); + } + updateCheckSchedule = setInterval( + () => autoUpdater.checkForUpdates(), + updateIntervalMs, + ); }; scheduleCheckForUpdates(); - autoUpdater.on('update-not-available', scheduleCheckForUpdates); + autoUpdater.on('update-available', () => { + clearInterval(updateCheckSchedule); + updateCheckSchedule = null; + }); autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { autoUpdater.setFeedURL({ url: getUpdateUrl(releaseName) });