| author | |
| committer | |
| log | 605e8143e09229d1c825f33afa26d1f2c10d8459 |
| tree | 1bc8bc3b09c78b1f841f36dba49c3af30fdff56e |
| parent | 5b056cd33750ee7ffb36faea836dc106bdeb973b |
- 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 races2 files changed, 14 insertions(+), 5 deletions(-)
apps/desktop/src/main.ts+6| ... | @@ -576,6 +576,12 @@ function shouldEnableAutoUpdates(): boolean { | ... | @@ -576,6 +576,12 @@ function shouldEnableAutoUpdates(): boolean { |
| 576 | 576 | ||
| 577 | async function checkForUpdates(reason: string): Promise<void> { | 577 | async function checkForUpdates(reason: string): Promise<void> { |
| 578 | if (!updaterConfigured || updateCheckInFlight) return; | 578 | 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 | } | ||
| 579 | updateCheckInFlight = true; | 585 | updateCheckInFlight = true; |
| 580 | setUpdateState({ | 586 | setUpdateState({ |
| 581 | status: "checking", | 587 | status: "checking", |
apps/web/src/components/Sidebar.tsx+8-5| ... | @@ -812,18 +812,21 @@ export default function Sidebar() { | ... | @@ -812,18 +812,21 @@ export default function Sidebar() { |
| 812 | } | 812 | } |
| 813 | 813 | ||
| 814 | let disposed = false; | 814 | 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 | |||
| 815 | void bridge | 822 | void bridge |
| 816 | .getUpdateState() | 823 | .getUpdateState() |
| 817 | .then((nextState) => { | 824 | .then((nextState) => { |
| 818 | if (disposed) return; | 825 | if (disposed || receivedSubscriptionUpdate) return; |
| 819 | setDesktopUpdateState(nextState); | 826 | setDesktopUpdateState(nextState); |
| 820 | }) | 827 | }) |
| 821 | .catch(() => undefined); | 828 | .catch(() => undefined); |
| 822 | 829 | ||
| 823 | const unsubscribe = bridge.onUpdateState((nextState) => { | ||
| 824 | setDesktopUpdateState(nextState); | ||
| 825 | }); | ||
| 826 | |||
| 827 | return () => { | 830 | return () => { |
| 828 | disposed = true; | 831 | disposed = true; |
| 829 | unsubscribe(); | 832 | unsubscribe(); |