fix event och tappa decoder connect

This commit is contained in:
larssand
2026-03-27 18:12:44 +01:00
parent aeaca807f1
commit f3b5216a2b
3 changed files with 70 additions and 19 deletions

View File

@@ -171,14 +171,29 @@ export async function pingBackendHelper({ backend, t, getBackendUrl }) {
}
}
export async function checkAppVersionHelper({ getBackendUrl, getBaselineAppVersion, setBaselineAppVersion }) {
export async function checkAppVersionHelper({ getBackendUrl, getBaselineAppVersion, setBaselineAppVersion, getPendingAppVersion, setPendingAppVersion, getLocalStateDirty }) {
try {
const res = await fetch(`${getBackendUrl()}/api/app-version`, { cache: "no-store" });
if (!res.ok) return;
const payload = await res.json();
const key = `${payload.revision}:${payload.updatedAt}`;
if (!getBaselineAppVersion()) { setBaselineAppVersion(key); return; }
if (key !== getBaselineAppVersion()) window.location.reload();
if (!getBaselineAppVersion()) {
setBaselineAppVersion(key);
setPendingAppVersion("");
return;
}
if (key === getBaselineAppVersion()) {
setPendingAppVersion("");
return;
}
if (getPendingAppVersion() !== key) {
setPendingAppVersion(key);
return;
}
if (getLocalStateDirty()) {
return;
}
window.location.reload();
} catch {}
}
@@ -186,7 +201,7 @@ export function startAppVersionPollingHelper({ checkAppVersion, getAppVersionPol
if (!window.location.protocol.startsWith("http")) return;
clearInterval(getAppVersionPollTimer());
checkAppVersion();
setAppVersionPollTimer(setInterval(checkAppVersion, 3000));
setAppVersionPollTimer(setInterval(checkAppVersion, 5000));
}
export function startOverlaySyncHelper({ getOverlaySyncTimer, setOverlaySyncTimer, getLocalStateDirty, hydrateFromBackend, getCurrentView, renderView }) {