Fix paused timer auto-resuming on page navigation
applySnapshot was always setting isPaused = false and blockStartedAt = Date.now() regardless of the actual timer state, causing a paused block to appear running whenever the dashboard was reloaded. - Add is_paused field to DashboardSnapshot schema - Dashboard endpoint derives is_paused by checking whether the last start/resume/pause event for the current block is a pause - applySnapshot now reads is_paused from the snapshot instead of resetting to false, and only sets blockStartedAt when the block is actually running (not paused) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -35,7 +35,7 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
session.value = snapshot.session
|
||||
blocks.value = sortBlocksByTime(snapshot.blocks)
|
||||
completedBlockIds.value = snapshot.completed_block_ids || []
|
||||
isPaused.value = false
|
||||
isPaused.value = snapshot.is_paused || false
|
||||
if (snapshot.child) child.value = snapshot.child
|
||||
dayStartTime.value = snapshot.day_start_time || null
|
||||
dayEndTime.value = snapshot.day_end_time || null
|
||||
@@ -43,7 +43,8 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
const serverElapsed = snapshot.block_elapsed_seconds || 0
|
||||
if (snapshot.session?.current_block_id && serverElapsed > 0) {
|
||||
blockElapsedOffset.value = serverElapsed
|
||||
blockStartedAt.value = Date.now()
|
||||
// Only start the live counter if the block is actually running (not paused)
|
||||
blockStartedAt.value = isPaused.value ? null : Date.now()
|
||||
} else {
|
||||
blockElapsedOffset.value = 0
|
||||
blockStartedAt.value = null
|
||||
|
||||
Reference in New Issue
Block a user