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:
@@ -44,10 +44,11 @@ export const useScheduleStore = defineStore('schedule', () => {
|
|||||||
morningRoutine.value = snapshot.morning_routine || []
|
morningRoutine.value = snapshot.morning_routine || []
|
||||||
// Restore elapsed time from server-computed value and seed the per-block cache
|
// Restore elapsed time from server-computed value and seed the per-block cache
|
||||||
const serverElapsed = snapshot.block_elapsed_seconds || 0
|
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
|
blockElapsedCache.value[snapshot.session.current_block_id] = serverElapsed
|
||||||
blockElapsedOffset.value = 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()
|
blockStartedAt.value = isPaused.value ? null : Date.now()
|
||||||
} else {
|
} else {
|
||||||
blockElapsedOffset.value = 0
|
blockElapsedOffset.value = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user