diff --git a/CHANGELOG.md b/CHANGELOG.md index aed8a0b..db3e292 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,13 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.45.2 - 2026-11-01 + +### Fixed + +- **Restarting a heat: "Reset data" now resets the clock too.** It cleared the laps but left the heat finished with its old clock, so it couldn't be started again. A reset heat (and a race's seeding practice) is back to "ready" - clock at zero, Start offered again. The cleared result is also written straight to the server, so a reset right after the last lap is no longer undone. Open Practice keeps "Reset – new practice day", which clears the laps and keeps running. +- **Race Day: a finished heat could not be picked again.** The session list hid finished heats of a race dated another day - e.g. after midnight - and of races without a date. A race now stays listed when anything in it ran in the last 12 hours, and undated races are always listed in full. + ## 1.45.1 - 2026-10-31 ### Changed diff --git a/package-lock.json b/package-lock.json index 1ed0ab1..7731607 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.45.1", + "version": "1.45.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.45.1", + "version": "1.45.2", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index 1cbfac9..13b006f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.45.1", + "version": "1.45.2", "private": true, "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "engines": { diff --git a/src/app.js b/src/app.js index 8db2999..5496844 100644 --- a/src/app.js +++ b/src/app.js @@ -357,11 +357,21 @@ function resetSessionData(session) { session.resultsResetAt = Date.now(); delete state.resultsBySession[session.id]; session.followUpStartedAt = null; + // A heat (anything but an Open/Free Practice that runs all evening) goes back to "ready": + // the clock is back at zero and it can be started again. + const rerunHeat = !isPracticeSessionType(session.type) && session.status !== "running"; + if (rerunHeat) { + // An empty result, also written straight to the server: a plain delete was put back by + // the server's live-results protection when the reset came right after the last lap. + ensureSessionResult(session.id); + Object.assign(session, { status: "ready", startedAt: null, endedAt: null, finishedByTimer: false, pausedAt: null, totalPausedMs: 0, followUpPausedMs: 0, audioAnnouncements: [] }); + } lastFinishAnnouncementSessionId = null; delete lastOverlayLeaderKeyBySession[session.id]; delete lastOverlayTop3BySession[session.id]; overlayEvents = []; saveState(); + if (rerunHeat) void persistSessionResultToBackend(session.id); renderView(); return true; } @@ -953,8 +963,8 @@ const TRANSLATIONS = { "race_day.show_all_sessions": "Visa alla sessioner", "race_day.go_next": "Nästa: {name}", "race_day.hidden_sessions": "({count} från andra dagar dolda)", - "race_day.reset_session_hint": "Nollställer sessionens varv och resultat, t.ex. vid omstart. Pausa först om heatet körs.", - "race_day.reset_session_confirm": "Nollställ alla varv och resultat i \"{name}\"?\n\nDet går inte att ångra.", + "race_day.reset_session_hint": "Nollställer sessionens varv, resultat och klocka så att den kan köras om. Pausa först om heatet körs.", + "race_day.reset_session_confirm": "Nollställ alla varv och resultat i \"{name}\" och ställ klockan på noll så att den kan startas om?\n\nDet går inte att ångra.", "race_day.new_practice_day": "Nollställ – ny träningsdag", "race_day.new_practice_day_hint": "Nollställer dagens varv i tidtagningen. Alla varv finns kvar i träningsstatistiken.", "race_day.new_practice_day_confirm": "Starta en ny träningsdag i \"{name}\"?\n\nDagens varv nollställs i tidtagningen (topplistan börjar om). Alla varv finns kvar i träningsstatistiken.", @@ -2822,8 +2832,8 @@ const TRANSLATIONS = { "race_day.show_all_sessions": "Show all sessions", "race_day.go_next": "Next: {name}", "race_day.hidden_sessions": "({count} from other days hidden)", - "race_day.reset_session_hint": "Clears the session's laps and results, e.g. for a restart. Pause first if the heat is running.", - "race_day.reset_session_confirm": "Clear every lap and result in \"{name}\"?\n\nThis cannot be undone.", + "race_day.reset_session_hint": "Clears the session's laps, results and clock so it can be run again. Pause first if the heat is running.", + "race_day.reset_session_confirm": "Clear every lap and result in \"{name}\" and set its clock back to zero so it can be started again?\n\nThis cannot be undone.", "race_day.new_practice_day": "Reset – new practice day", "race_day.new_practice_day_hint": "Clears today's laps in timing. Every lap stays in the training statistics.", "race_day.new_practice_day_confirm": "Start a new practice day in \"{name}\"?\n\nToday's laps are cleared in timing (the leaderboard starts over). Every lap stays in the training statistics.", diff --git a/src/race_day_view.js b/src/race_day_view.js index bfd90f1..f37bcaf 100644 --- a/src/race_day_view.js +++ b/src/race_day_view.js @@ -70,14 +70,17 @@ const localDateKey = (date = new Date()) => `${date.getFullYear()}-${String(date // The session picker lists today's races by default (plus whatever is live or selected), // grouped per race in the order they were set up. Old races, practices and other series' -// rounds stay out of the way until "Show all" is ticked. Undated races show unrun sessions. -export function buildRaceDaySessionGroups({ sessions, events, selectedId = "", showAll = false, today = localDateKey() }) { +// rounds stay out of the way until "Show all" is ticked. +export function buildRaceDaySessionGroups({ sessions, events, selectedId = "", showAll = false, today = localDateKey(), now = Date.now() }) { const eventById = new Map((events || []).map((event) => [event.id, event])); const isLive = (session) => ["running", "paused"].includes(session.status); + // A race is "today's" by its date, or when something in it ran in the last 12 hours (a + // race day going past midnight, a date set wrong). Undated races are always listed. + const recentEventIds = new Set((sessions || []).filter((session) => Number(session.startedAt) > now - 12 * 3600 * 1000).map((session) => session.eventId)); const visible = (session) => { - if (showAll || isLive(session) || session.id === selectedId) return true; + if (showAll || isLive(session) || session.id === selectedId || recentEventIds.has(session.eventId)) return true; const date = eventById.get(session.eventId)?.date; - return date ? date === today : session.status === "ready"; + return !date || date === today; }; const groups = new Map(); let hidden = 0; @@ -240,6 +243,9 @@ export function renderRaceDayView(deps) { const sessionChoices = buildRaceDaySessionGroups({ sessions: state.sessions, events: state.events, selectedId: session?.id, showAll: showAllSessions }); const isPracticeSession = Boolean(session && (isPracticeSessionType(session.type) || session.type === "practice")); const isLiveSession = ["running", "paused"].includes(session?.status); + // Open/Free Practice runs all evening and is reset per day; a race's practice (seeding) is + // reset like a heat. + const isOpenPractice = Boolean(session && isPracticeSessionType(session.type)); // Layouts are a practice thing: never offered while a race session is in focus. const layoutAllowed = !session || isPracticeSessionType(session.type); dom.view.innerHTML = ` @@ -289,7 +295,7 @@ export function renderRaceDayView(deps) { ${session?.status === "running" ? `` : ""} ${session?.status === "paused" ? `` : ""} ${isLiveSession ? `` : ""} - ${isPracticeSession ? `` + ${isOpenPractice ? `` : session && session.status !== "running" ? `` : ""}`} ${isPracticeSession ? "" : `