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:
@@ -170,6 +170,17 @@ async def timer_action(
|
||||
if not session:
|
||||
raise HTTPException(status_code=404, detail="Session not found")
|
||||
|
||||
# When starting a different block, implicitly pause the previous one so
|
||||
# the activity log stays accurate and elapsed time is preserved correctly.
|
||||
if body.event_type == "start" and body.block_id is not None:
|
||||
prev_block_id = session.current_block_id
|
||||
if prev_block_id and prev_block_id != body.block_id:
|
||||
db.add(TimerEvent(
|
||||
session_id=session.id,
|
||||
block_id=prev_block_id,
|
||||
event_type="pause",
|
||||
))
|
||||
|
||||
# Update current block if provided
|
||||
if body.block_id is not None:
|
||||
session.current_block_id = body.block_id
|
||||
|
||||
Reference in New Issue
Block a user