Fehler bei Stay on first site

This commit is contained in:
Erik Thiele
2026-06-22 17:01:32 +02:00
parent 259626afbc
commit ab83c19997
2 changed files with 25 additions and 8 deletions

View File

@@ -352,10 +352,10 @@ updateClock();
const normalFiles = {{ normal_files | tojson }};
const prioFiles = {{ prio_files | tojson }};
const interval = {{ interval }} * 1000;
const stayOnFirst = {{ "true" if stay_on_first else "false" }};
const screen = "{{ screen }}";
const site = "{{ site }}";
// stayOnFirst: Player bleibt auf erstem Element (kein Timer/Advance)
let stayOnFirst = {{ "true" if stay_on_first else "false" }};
const screen = "{{ screen }}";
const site = "{{ site }}";
// stayOnFirst: Player bleibt auf erstem Element (kein Timer/Advance)
// ─── Player-Status ───
let normalIndex = 0;
@@ -488,13 +488,27 @@ function playNext() {
}
}
// ─── Auto-Reload bei Playlist-Änderungen ───
// ─── Auto-Reload bei Playlist-Änderungen + dynamisches stayOnFirst ───
let lastHash = null;
async function checkForUpdates() {
try {
const res = await fetch(`/playlist/${site}/${screen}/hash`, { cache: "no-store" });
const hash = await res.text();
const data = await res.json();
const hash = data.hash;
const serverStayOnFirst = data.stay_on_first;
// Dynamisch stayOnFirst vom Server übernehmen
const wasStopped = stayOnFirst === true;
stayOnFirst = serverStayOnFirst;
// Wenn stayOnFirst gerade ausgeschaltet wurde → sofort weiterlaufen
if (wasStopped && !stayOnFirst) {
if (playerTimer) clearTimeout(playerTimer);
playNext();
}
// Hash-Änderung → Seite komplett neu laden
if (lastHash && lastHash !== hash) {
location.reload(true);
}