Show timer remaining per block and fix single-click block switching
- Block list on both dashboards now shows time remaining on each block's timer (allocated duration minus elapsed) instead of total duration; the active block counts down live every second - Fix block switching requiring 2 clicks: replace separate pause+start requests with a single start request; backend implicitly records a pause event for the previous block atomically - Export blockElapsedCache from store so views can compute per-block elapsed for both running and paused blocks Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,7 @@
|
||||
:block="block"
|
||||
:is-current="block.id === scheduleStore.session?.current_block_id"
|
||||
:is-completed="scheduleStore.completedBlockIds.includes(block.id)"
|
||||
:elapsed-seconds="blockElapsed(block)"
|
||||
compact
|
||||
/>
|
||||
</div>
|
||||
@@ -179,6 +180,14 @@ const currentSubjectOptions = computed(() =>
|
||||
scheduleStore.currentBlock?.subject?.options || []
|
||||
)
|
||||
|
||||
function blockElapsed(block) {
|
||||
const currentId = scheduleStore.session?.current_block_id
|
||||
if (block.id === currentId && scheduleStore.blockStartedAt && !scheduleStore.isPaused) {
|
||||
return scheduleStore.blockElapsedOffset + Math.floor((now.value - scheduleStore.blockStartedAt) / 1000)
|
||||
}
|
||||
return scheduleStore.blockElapsedCache[block.id] || 0
|
||||
}
|
||||
|
||||
// WebSocket
|
||||
const { connected: wsConnected } = useWebSocket(childId, (msg) => {
|
||||
scheduleStore.applyWsEvent(msg)
|
||||
|
||||
Reference in New Issue
Block a user