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:
1 parent
cea278518e
commit
5928ce847b
8 files changed
+76
-10
No files matched your search
@@ -227,11 +227,14 @@ export function createBackendSyncScheduler({ sync, isHidden = () => false, delay
|
||||
};
|
||||
}
|
||||
|
||||
export async function syncStateToBackendHelper({ backend, t, getBackendUrl, buildPersistableState, getLocalStateVersion, getSyncedStateVersion, setSyncedStateVersion, setLocalStateDirty }) {
|
||||
// getClientId: this tab's Race Controller id - the server keeps the race control (heat status,
|
||||
// laps, the active heat) out of saves from a browser that is not the master.
|
||||
export async function syncStateToBackendHelper({ backend, t, getBackendUrl, buildPersistableState, getLocalStateVersion, getSyncedStateVersion, setSyncedStateVersion, setLocalStateDirty, getClientId = () => "" }) {
|
||||
backend.pendingWrites = (backend.pendingWrites || 0) + 1;
|
||||
const syncVersion = getLocalStateVersion();
|
||||
try {
|
||||
const res = await fetch(`${getBackendUrl()}/api/state`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(buildPersistableState()) });
|
||||
const clientId = getClientId();
|
||||
const res = await fetch(`${getBackendUrl()}/api/state${clientId ? `?client=${encodeURIComponent(clientId)}` : ""}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(buildPersistableState()) });
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
backend.available = true;
|
||||
backend.lastError = "";
|
||||
|
||||
Reference in new issue
Block a user