TypeScript
Prevent redundant checks during desktop update download
Julius Marminge605e8143e092
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.tsindex e89cecbe917..9b7770a617b 100644--- a/apps/desktop/src/main.ts+++ b/apps/desktop/src/main.ts@@ -576,6 +576,12 @@ function shouldEnableAutoUpdates(): boolean {async function checkForUpdates(reason: string): Promise<void> {if (!updaterConfigured || updateCheckInFlight) return;+ if (updateState.status === "downloading" || updateState.status === "downloaded") {+ console.info(+ `[desktop-updater] Skipping update check (${reason}) while status=${updateState.status}.`,+ );+ return;+ }updateCheckInFlight = true;setUpdateState({status: "checking",diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsxindex 46f5ab3faa3..b6d49e235e8 100644--- a/apps/web/src/components/Sidebar.tsx+++ b/apps/web/src/components/Sidebar.tsx@@ -812,18 +812,21 @@ export default function Sidebar() {}let disposed = false;+ let receivedSubscriptionUpdate = false;+ const unsubscribe = bridge.onUpdateState((nextState) => {+ if (disposed) return;+ receivedSubscriptionUpdate = true;+ setDesktopUpdateState(nextState);+ });+void bridge.getUpdateState().then((nextState) => {- if (disposed) return;+ if (disposed || receivedSubscriptionUpdate) return;setDesktopUpdateState(nextState);}).catch(() => undefined);- const unsubscribe = bridge.onUpdateState((nextState) => {- setDesktopUpdateState(nextState);- });-return () => {disposed = true;unsubscribe();