fix: restore reliable update flow across sidebar and mobile

Show Update button in sidebar only when an update is available
Support update button on mobile sidebar and remove duplicate mobile Settings entry
Force desktop Tauri recheck and preflight before download to avoid missing pending updates
This commit is contained in:
Bohdan Triapitsyn
2026-03-20 02:04:33 +02:00
parent 321cc7252a
commit 03cec8d507
4 changed files with 116 additions and 9 deletions
+51 -2
View File
@@ -157,9 +157,43 @@ export const useUpdateStore = create<UpdateStore>()((set, get) => ({
let suggestedSec: number | null = null;
if (runtime === 'desktop') {
info = await checkForDesktopUpdates();
const sidecarInfo = await checkForWebUpdates('desktop', info?.currentVersion);
let desktopInfo = await checkForDesktopUpdates();
set({
checking: false,
available: desktopInfo?.available ?? false,
info: desktopInfo,
lastChecked: Date.now(),
nextCheckInSec: null,
});
const sidecarInfo = await checkForWebUpdates('desktop', desktopInfo?.currentVersion);
suggestedSec = sidecarInfo?.nextSuggestedCheckInSec ?? null;
if (sidecarInfo?.available && !desktopInfo?.available) {
const forcedDesktopInfo = await checkForDesktopUpdates();
if (forcedDesktopInfo) {
desktopInfo = forcedDesktopInfo;
}
}
if (sidecarInfo) {
const mergedInfo: UpdateInfo = {
...(desktopInfo ?? { available: false, currentVersion: sidecarInfo.currentVersion ?? 'unknown' }),
...sidecarInfo,
currentVersion: desktopInfo?.currentVersion ?? sidecarInfo.currentVersion ?? 'unknown',
available: sidecarInfo.available,
};
set({
available: mergedInfo.available,
info: mergedInfo,
nextCheckInSec: suggestedSec,
});
} else {
set({ nextCheckInSec: suggestedSec });
}
return suggestedSec;
} else if (runtime === 'web') {
info = await checkForWebUpdates('web');
suggestedSec = info?.nextSuggestedCheckInSec ?? null;
@@ -196,6 +230,21 @@ export const useUpdateStore = create<UpdateStore>()((set, get) => ({
set({ downloading: true, error: null, progress: null });
try {
const desktopInfo = await checkForDesktopUpdates();
if (!desktopInfo?.available) {
throw new Error('Update detected, but desktop package is not ready yet. Retry in a moment.');
}
set((state) => ({
info: state.info
? {
...state.info,
...desktopInfo,
available: state.info.available,
}
: desktopInfo,
}));
const ok = await downloadDesktopUpdate((progress) => {
set({ progress });
});