fix(timing): keep timing the running session when another one is selected

Passings and the session clock followed only the selected session, so
selecting another practice or the next heat while one was running
dropped every lap. They now go to the running session, and Timing and
Race Day show where laps are being recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
larssandandClaude Opus 5.5 committed 2026-10-17 17:31:59 +02:00
1 parent cdde070c1c
commit 3a6789f42f
13 files changed
+137 -13

No files matched your search

+12
View File
@@ -25,6 +25,18 @@ export function getActiveSession({ state }) {
return state.sessions.find((s) => s.id === state.activeSessionId) || null;
}
// The session that is actually being timed. Normally the selected one; but if the selected
// session isn't running or paused (the next heat picked on Race Day, another Open Practice
// opened) while another session still runs, that running one - the most recently started -
// keeps getting the passings and its clock, instead of every lap being dropped.
export function getLiveSession({ state }) {
const isLive = (session) => ["running", "paused"].includes(String(session?.status || ""));
const active = getActiveSession({ state });
if (isLive(active)) return active;
const live = state.sessions.filter(isLive).sort((a, b) => Number(b.startedAt || 0) - Number(a.startedAt || 0));
return live[0] || active;
}
export function getSessionTargetMs(session, { isUntimedSession }) {