fix(sync): a browser that is not the race master can't change heats, laps or the active heat (1.89.38)

This commit is contained in:
larssand committed 2026-11-15 16:55:58 +01:00
1 parent cea278518e
commit 5928ce847b
8 files changed
+76 -10

No files matched your search

+6 -2
View File
@@ -6,7 +6,7 @@ const { spawn, execFile } = require("child_process");
const express = require("express");
const QRCode = require("qrcode");
const Database = require("better-sqlite3");
const { keepStartedSessions } = require("./server/session_guard.js");
const { keepStartedSessions, keepRaceControl } = require("./server/session_guard.js");
const publicTrainingProfile = require("./server/public_training_profile");
const { createBackupService } = require("./server/backup_service");
const { createAuth, COOKIE_NAME: AUTH_COOKIE_NAME, TOKEN_MAX_AGE_MS } = require("./server/auth");
@@ -508,7 +508,11 @@ app.post("/api/state", (req, res) => {
}
const stored = readStoredAppState();
const { state: guarded, kept } = keepStartedSessions(req.body, stored?.state);
// Not the master (a second computer showing the race): the race control stays the master's.
const master = liveController();
const clientId = String(req.query?.client || "");
const fromFollower = Boolean(master && clientId && clientId !== master.clientId);
const { state: guarded, kept } = keepStartedSessions(fromFollower ? keepRaceControl(req.body, stored?.state) : req.body, stored?.state);
if (kept.length) console.log(`[state] Kept ${kept.length} run heat(s) a save from an older copy tried to put back to ready: ${kept.join(", ")}`);
const stateJson = JSON.stringify(protectRecentSessionResults(guarded, stored));
const nowIso = new Date().toISOString();