add blocker presets

This commit is contained in:
timka123 committed 2026-10-19 11:54:15 +03:00
1 parent 2be074f191
commit 772fdbfded
12 files changed
+426 -83

No files matched your search

+19
View File
@@ -216,6 +216,25 @@ def extend(session: Session, minutes: int) -> PomodoroSession:
return row
def rescale_current(session: Session, settings: AppSettings) -> PomodoroSession | None:
"""Resize the running/paused interval to match a just-saved duration.
Without this, a preset (or any Focus/Short/Long edit) only takes effect
from the *next* interval — the one already ticking keeps whatever length
it was born with. `elapsed_seconds` is wall-clock, not stored, so this
only has to move `planned_seconds`; time already spent still counts, it
is just measured against the new total.
"""
row = current_session(session)
if row is None:
return None
planned = duration_for(settings, row.kind) # type: ignore[arg-type]
if planned != row.planned_seconds:
row.planned_seconds = planned
session.commit()
return row
def attach_task(session: Session, task_id: int | None) -> PomodoroSession:
row = _require_active(session)
if task_id is None: