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
This commit is contained in:
Julius Marminge authored and Julius Marminge committed 2026-03-03 22:31:45 -08:00
1 parent 5b056cd337
commit 605e8143e0
2 files changed
+14 -5

No files matched your search

+6
View File
@@ -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",
+8 -5
View File
@@ -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();