fix(race-day): reset a heat to ready with its clock at zero, keep recent races listed (1.45.2)
This commit is contained in:
1 parent
7376595001
commit
ab1c26a89b
7 files changed
+62
-14
No files matched your search
+11
-5
@@ -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" ? `<button id="raceDayPause" class="btn btn-danger" type="button">⏸ ${t(isPracticeSession ? "race_day.pause_practice" : "audio.race_pause")}</button>` : ""}
|
||||
${session?.status === "paused" ? `<button id="raceDayResume" class="btn btn-go" type="button">${t(isPracticeSession ? "race_day.resume_practice" : "audio.race_resume")}</button>` : ""}
|
||||
${isLiveSession ? `<button id="raceDayFinish" class="btn btn-checkered" type="button">🏁 ${t(isPracticeSession ? "race_day.finish_practice" : "race_day.finish")}</button>` : ""}
|
||||
${isPracticeSession ? `<button id="raceDayNewPracticeDay" class="btn" type="button" title="${escapeHtml(t("race_day.new_practice_day_hint"))}">${t("race_day.new_practice_day")}</button>`
|
||||
${isOpenPractice ? `<button id="raceDayNewPracticeDay" class="btn" type="button" title="${escapeHtml(t("race_day.new_practice_day_hint"))}">${t("race_day.new_practice_day")}</button>`
|
||||
: session && session.status !== "running" ? `<button id="raceDayResetSession" class="btn" type="button" title="${escapeHtml(t("race_day.reset_session_hint"))}">${t("timing.reset")}</button>` : ""}`}
|
||||
</div>
|
||||
${isPracticeSession ? "" : `<div id="raceDayStartLights" class="race-start-lights" data-state="${escapeHtml(getStartLightState())}">
|
||||
|
||||
Reference in new issue
Block a user