fix(control): pause, resume, false start and reset are master-only too (1.77.1)

This commit is contained in:
larssand committed 2026-11-07 17:48:25 +01:00
1 parent cf3a4c5fdb
commit 0589fe5f65
8 files changed
+35 -9

No files matched your search

+5 -2
View File
@@ -256,7 +256,7 @@ const announceRaceFinished = (finished = null) => {
const announceRaceClockEvent = (eventKey, session) => triggerRaceAudio(eventKey, { logData: { raceId: session.eventId, sessionId: session.id } });
const handleSessionTimerTick = () => handleSessionTimerTickHelper({ getActiveSession: getLiveSession, isUntimedSession, getSessionTiming, saveState, getLastFinishAnnouncementSessionId: () => lastFinishAnnouncementSessionId, setLastFinishAnnouncementSessionId: (value) => { lastFinishAnnouncementSessionId = value; }, announceRaceFinished, announceRaceClockEvent,
// The race browser: the one on the decoder, or with no decoder anywhere, the one that started the heat.
isClockOwner: (session) => !overlayMode && (Boolean(state.decoder?.connected) || readClockOwner() === session.id),
isClockOwner: (session) => !overlayMode && isRaceMaster() && (Boolean(state.decoder?.connected) || readClockOwner() === session.id),
getFinishWait: (session) => getFinishWaitLogic(session, state.resultsBySession[session.id]?.competitors, { maxLapMs: getSessionLapWindow(session).maxLapMs }) });
const CLOCK_OWNER_KEY = "rc_clock_owner";
const readClockOwner = () => { try { return sessionStorage.getItem(CLOCK_OWNER_KEY) || ""; } catch { return ""; } };
@@ -540,6 +540,7 @@ const bindDayCall = (root) => bindDayCallBanner(root, {
});
// Pausing the day stops the autopilot and pauses whatever is on track (or holds the count-down).
function pauseRaceDay(date) {
if (!isRaceMaster()) { notifyNotMaster(); return; }
saveDayPlan({ ...getDayPlan(date), pausedAt: Date.now() });
const live = state.sessions.find((session) => session.status === "running");
if (live) pauseOperationalSession(live);
@@ -547,6 +548,7 @@ function pauseRaceDay(date) {
renderView();
}
function resumeRaceDay(date) {
if (!isRaceMaster()) { notifyNotMaster(); return; }
saveDayPlan({ ...getDayPlan(date), pausedAt: null });
const paused = state.sessions.find((session) => session.status === "paused" && session.mode === "race" && !isPracticeSessionType(session.type));
if (paused) resumeOperationalSession(paused);
@@ -601,6 +603,7 @@ function currentSession(session) {
function resetSessionData(session) {
session = currentSession(session);
if (!session) return false;
if (!isRaceMaster()) { notifyNotMaster(); return false; }
syncTrainingLedger();
session.resultsResetAt = Date.now();
delete state.resultsBySession[session.id];
@@ -813,7 +816,7 @@ const renderTiming = () => renderTimingView({ renderSuspectLapsPanel: (session)
// Speaker panel (race-control calls, quick sound switches) on Race Day and Judging.
const speakerPanelDeps = {
renderSpeakerPanel: () => renderSpeakerPanel({ state, t, escapeHtml }),
bindSpeakerPanel: (root) => bindSpeakerPanel(root, { state, getActiveSession, cancelRaceStart, triggerRaceAudio, saveState, updateHeaderState, renderView }),
bindSpeakerPanel: (root) => bindSpeakerPanel(root, { state, getActiveSession, cancelRaceStart, triggerRaceAudio, saveState, updateHeaderState, renderView, canRunRace: isRaceMaster, notifyNotMaster }),
};
const renderJudging = () => renderJudgingView({ ...speakerPanelDeps,
getJudgingSession, setJudgingSessionId: (value) => { judgingSessionId = value; }, getJudgingSessionChoices,
+6 -1
View File
@@ -46,12 +46,17 @@ export function renderSpeakerPanel({ state, t, escapeHtml }) {
</section>`;
}
export function bindSpeakerPanel(root, { state, getActiveSession, cancelRaceStart, triggerRaceAudio, saveState, updateHeaderState, renderView }) {
export function bindSpeakerPanel(root, { state, getActiveSession, cancelRaceStart, triggerRaceAudio, saveState, updateHeaderState, renderView, canRunRace = () => true, notifyNotMaster = () => {} }) {
if (!root) return;
root.querySelectorAll("#speakerPanel [data-race-audio-cue]").forEach((node) => {
node.addEventListener("click", () => {
const cue = node.dataset.raceAudioCue;
const session = getActiveSession();
// Pause, resume and false start change the heat: only the Race Controller Master may.
if (["false_start", "race_paused", "race_resumed"].includes(cue) && !canRunRace()) {
notifyNotMaster();
return;
}
if (cue === "false_start") {
cancelRaceStart();
} else if (cue === "race_paused" && session?.status === "running") {