fix: streak counter showing zero on second device due to stale localStorage
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:
2026-02-15 22:06:21 +01:00
parent 8c984f3064
commit a435a1142f
2 changed files with 6 additions and 9 deletions

View File

@@ -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() {