authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-03-03 19:21:09-08:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-03-03 22:31:45-08:00
log605e8143e09229d1c825f33afa26d1f2c10d8459
tree1bc8bc3b09c78b1f841f36dba49c3af30fdff56e
parent5b056cd33750ee7ffb36faea836dc106bdeb973b

Prevent redundant checks during desktop update download

- Skip desktop auto-update checks while an update is downloading or already downloaded - Subscribe to update-state events before initial fetch in sidebar to avoid stale state races

2 files changed, 14 insertions(+), 5 deletions(-)

apps/desktop/src/main.ts+6
......@@ -576,6 +576,12 @@ function shouldEnableAutoUpdates(): boolean {
576576
577577async function checkForUpdates(reason: string): Promise<void> {
578578 if (!updaterConfigured || updateCheckInFlight) return;
579 if (updateState.status === "downloading" || updateState.status === "downloaded") {
580 console.info(
581 `[desktop-updater] Skipping update check (${reason}) while status=${updateState.status}.`,
582 );
583 return;
584 }
579585 updateCheckInFlight = true;
580586 setUpdateState({
581587 status: "checking",
apps/web/src/components/Sidebar.tsx+8-5
......@@ -812,18 +812,21 @@ export default function Sidebar() {
812812 }
813813
814814 let disposed = false;
815 let receivedSubscriptionUpdate = false;
816 const unsubscribe = bridge.onUpdateState((nextState) => {
817 if (disposed) return;
818 receivedSubscriptionUpdate = true;
819 setDesktopUpdateState(nextState);
820 });
821
815822 void bridge
816823 .getUpdateState()
817824 .then((nextState) => {
818 if (disposed) return;
825 if (disposed || receivedSubscriptionUpdate) return;
819826 setDesktopUpdateState(nextState);
820827 })
821828 .catch(() => undefined);
822829
823 const unsubscribe = bridge.onUpdateState((nextState) => {
824 setDesktopUpdateState(nextState);
825 });
826
827830 return () => {
828831 disposed = true;
829832 unsubscribe();