fix timers
lint / ruff (push) Failing after 15s
tests / desktop (push) Successful in 21s
tests / web (push) Successful in 46s
docker / image (push) Failing after 1m31s
tests / android-core (push) Successful in 1m5s
tests / backend (push) Successful in 2m33s
android / apk (push) Successful in 4m34s

This commit is contained in:
timka123 committed 2026-10-27 18:52:54 +03:00
1 parent ff77d8f89f
commit 157a113c39
30 files changed
+3331 -419

No files matched your search

+22 -4
View File
@@ -176,10 +176,28 @@ def resume(session: Session) -> PomodoroSession:
def complete(
session: Session, settings: AppSettings, *, auto_next: bool = True
) -> tuple[PomodoroSession, PomodoroSession | None]:
"""Finish the current interval and, if configured, roll into the next one."""
row = _require_active(session)
session: Session,
settings: AppSettings,
*,
auto_next: bool = True,
expect_id: int | None = None,
) -> tuple[PomodoroSession | None, PomodoroSession | None]:
"""Finish the current interval and, if configured, roll into the next one.
`expect_id` is the interval the caller believes it is finishing. Every
client runs its own local countdown and calls this when it hits zero, so
two clients open at once both call within the same second — and the second
call used to land on the interval `auto_next` had just created and end it
immediately. That is a break disappearing the moment it starts, and it is
not something a client can fix on its own: only the server knows which
interval is current. So a call that names an interval which is no longer
running does nothing at all, and says so by returning no `finished`.
"""
row = current_session(session)
if expect_id is not None and (row is None or row.id != expect_id):
return None, None
if row is None:
raise TimerError("No interval is running.")
finished = _finish(session, settings, row, status="completed")
follow_on: PomodoroSession | None = None