Add Reset button and move End Day to right side of actions bar
Reset clears the current block's elapsed time to zero and immediately starts the timer. A shared compute_block_elapsed() utility (utils/timer.py) handles the elapsed calculation in both the sessions and dashboard routers, and correctly treats "reset" events as zero-elapsed restart markers so page reloads after a reset show accurate times. Layout: Start/Pause/Resume/Reset are grouped on the left; End Day sits on the right via justify-content: space-between. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -101,6 +101,13 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
blockStartedAt.value = Date.now()
|
||||
isPaused.value = false
|
||||
}
|
||||
// Reset — clear elapsed to 0 and start counting immediately
|
||||
if (event.event === 'reset') {
|
||||
if (event.block_id) blockElapsedCache.value[event.block_id] = 0
|
||||
blockElapsedOffset.value = 0
|
||||
blockStartedAt.value = Date.now()
|
||||
isPaused.value = false
|
||||
}
|
||||
// Select — switch current block but keep timer stopped (manual start required)
|
||||
if (event.event === 'select') {
|
||||
// Sync the previous block's cache
|
||||
@@ -204,6 +211,17 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
sendTimerAction(sessionId, 'start', session.value.current_block_id)
|
||||
}
|
||||
|
||||
// Reset the current block's timer to 0 and start counting immediately.
|
||||
function resetCurrentBlock(sessionId) {
|
||||
if (!session.value?.current_block_id) return
|
||||
const blockId = session.value.current_block_id
|
||||
blockElapsedCache.value[blockId] = 0
|
||||
blockElapsedOffset.value = 0
|
||||
isPaused.value = false
|
||||
blockStartedAt.value = Date.now()
|
||||
sendTimerAction(sessionId, 'reset', blockId)
|
||||
}
|
||||
|
||||
return {
|
||||
session,
|
||||
blocks,
|
||||
@@ -226,5 +244,6 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
switchBlock,
|
||||
selectBlock,
|
||||
startCurrentBlock,
|
||||
resetCurrentBlock,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user