| ... | ... | @@ -203,6 +203,7 @@ function getDestructiveMenuIcon(): Electron.NativeImage | undefined { |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | let updatePollTimer: ReturnType<typeof setInterval> | null = null; |
| 206 | let updateStartupTimer: ReturnType<typeof setTimeout> | null = null; |
| 206 | 207 | let updateCheckInFlight = false; |
| 207 | 208 | let updateDownloadInFlight = false; |
| 208 | 209 | let updaterConfigured = false; |
| ... | ... | @@ -538,9 +539,14 @@ function configureAppIdentity(): void { |
| 538 | 539 | } |
| 539 | 540 | |
| 540 | 541 | function clearUpdatePollTimer(): void { |
| 541 | | if (!updatePollTimer) return; |
| 542 | | clearInterval(updatePollTimer); |
| 543 | | updatePollTimer = null; |
| 542 | if (updateStartupTimer) { |
| 543 | clearTimeout(updateStartupTimer); |
| 544 | updateStartupTimer = null; |
| 545 | } |
| 546 | if (updatePollTimer) { |
| 547 | clearInterval(updatePollTimer); |
| 548 | updatePollTimer = null; |
| 549 | } |
| 544 | 550 | } |
| 545 | 551 | |
| 546 | 552 | function emitUpdateState(): void { |
| ... | ... | @@ -570,7 +576,7 @@ function shouldEnableAutoUpdates(): boolean { |
| 570 | 576 | } |
| 571 | 577 | |
| 572 | 578 | async function checkForUpdates(reason: string): Promise<void> { |
| 573 | | if (!updaterConfigured || updateCheckInFlight) return; |
| 579 | if (isQuitting || !updaterConfigured || updateCheckInFlight) return; |
| 574 | 580 | if ( |
| 575 | 581 | updateState.status === "downloading" || |
| 576 | 582 | updateState.status === "downloaded" || |
| ... | ... | @@ -739,10 +745,13 @@ function configureAutoUpdater(): void { |
| 739 | 745 | console.info(`[desktop-updater] Update downloaded: ${info.version}`); |
| 740 | 746 | }); |
| 741 | 747 | |
| 742 | | const startupTimer = setTimeout(() => { |
| 748 | clearUpdatePollTimer(); |
| 749 | |
| 750 | updateStartupTimer = setTimeout(() => { |
| 751 | updateStartupTimer = null; |
| 743 | 752 | void checkForUpdates("startup"); |
| 744 | 753 | }, AUTO_UPDATE_STARTUP_DELAY_MS); |
| 745 | | startupTimer.unref(); |
| 754 | updateStartupTimer.unref(); |
| 746 | 755 | |
| 747 | 756 | updatePollTimer = setInterval(() => { |
| 748 | 757 | void checkForUpdates("poll"); |