Fix TV timer not starting after reset (or fresh block start)

applySnapshot checked serverElapsed > 0 before setting blockStartedAt,
so any block with 0 elapsed (just reset, or started within the same
second) was loaded with blockStartedAt = null — the timer appeared frozen.

The condition now only checks for a current_block_id; the isPaused flag
already handles the "selected but not started" case correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-03 00:26:39 -08:00
parent 1420d57e7e
commit e70446a46e

View File

@@ -44,10 +44,11 @@ export const useScheduleStore = defineStore('schedule', () => {
morningRoutine.value = snapshot.morning_routine || []
// Restore elapsed time from server-computed value and seed the per-block cache
const serverElapsed = snapshot.block_elapsed_seconds || 0
if (snapshot.session?.current_block_id && serverElapsed > 0) {
if (snapshot.session?.current_block_id) {
blockElapsedCache.value[snapshot.session.current_block_id] = serverElapsed
blockElapsedOffset.value = serverElapsed
// Only start the live counter if the block is actually running (not paused)
// Start the live counter only when the block is actually running (not paused).
// Use serverElapsed == 0 is fine here — a just-reset block is still running.
blockStartedAt.value = isPaused.value ? null : Date.now()
} else {
blockElapsedOffset.value = 0