fix: streak counter showing zero on second device due to stale localStorage
All checks were successful
CI / update (push) Successful in 1m30s
All checks were successful
CI / update (push) Successful in 1m30s
The RosaryStreakStore singleton survives client-side navigation but the first mount. Also reorder onMount to merge server data before assigning to streak, preventing a frame of stale localStorage values.
This commit is contained in:
@@ -30,9 +30,12 @@ const labels = $derived({
|
||||
});
|
||||
|
||||
// Initialize store on mount (client-side only)
|
||||
// Init with server data BEFORE assigning to streak, so displayLength
|
||||
// never sees stale localStorage data from the singleton
|
||||
onMount(() => {
|
||||
streak = getRosaryStreak();
|
||||
streak.initWithServerData(streakData, streakData !== null);
|
||||
const s = getRosaryStreak();
|
||||
s.initWithServerData(streakData, isLoggedIn);
|
||||
streak = s;
|
||||
});
|
||||
|
||||
async function pray() {
|
||||
|
||||
Reference in New Issue
Block a user