mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: prevent progress bar from jumping backwards during install
The store set an initial 5% optimistically, then SSE sent real progress starting from 0%, causing the bar to visibly drop. Now progress only moves forward — both SSE and polling paths use Math.max to never regress below the current value.
This commit is contained in:
@@ -68,7 +68,14 @@ export const useFeaturesStore = create<FeaturesState>((set, get) => {
|
|||||||
}
|
}
|
||||||
resolveCompletion(bundleId);
|
resolveCompletion(bundleId);
|
||||||
} else if (updated.progress) {
|
} else if (updated.progress) {
|
||||||
set({ installing: { ...get().installing, [bundleId]: updated.progress } });
|
const current = get().installing[bundleId];
|
||||||
|
const percent = Math.max(updated.progress.percent, current?.percent ?? 0);
|
||||||
|
set({
|
||||||
|
installing: {
|
||||||
|
...get().installing,
|
||||||
|
[bundleId]: { percent, stage: updated.progress.stage },
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
}, 3000);
|
}, 3000);
|
||||||
@@ -106,10 +113,12 @@ export const useFeaturesStore = create<FeaturesState>((set, get) => {
|
|||||||
resolveCompletion(bundleId);
|
resolveCompletion(bundleId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const current = get().installing[bundleId];
|
||||||
|
const percent = Math.max(data.percent, current?.percent ?? 0);
|
||||||
set({
|
set({
|
||||||
installing: {
|
installing: {
|
||||||
...get().installing,
|
...get().installing,
|
||||||
[bundleId]: { percent: data.percent, stage: data.stage },
|
[bundleId]: { percent, stage: data.stage },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|||||||
Reference in New Issue
Block a user