diff --git a/changelog.md b/changelog.md index d62d38b..a7f3aa1 100755 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## v1.4.11 (2026-02-24) +- **Feature**: Das Versionsmenü prüft nun im Hintergrund direkt beim Öffnen nach neuen Versionen und aktualisiert die Liste automatisch, selbst wenn eine veraltete Liste noch im Cache liegt. + ## v1.4.10 (2026-02-24) - **Fix**: Die Farben der Benachrichtigungs-Glocke wurden korrigiert: Sie ist nun gelb, während man auf ein Menü wartet, und wird grün, sobald eines verfügbar ist. diff --git a/kantine.js b/kantine.js index f0b5f7c..efa21b5 100755 --- a/kantine.js +++ b/kantine.js @@ -2002,19 +2002,8 @@ const dm = devToggle.checked; container.innerHTML = '
Lade Versionen...
'; - try { - let versions; - const cached = JSON.parse(localStorage.getItem('kantine_version_cache') || 'null'); - if (!forceRefresh && cached && cached.devMode === dm && (Date.now() - cached.timestamp < 3600000)) { - versions = cached.versions; - } else { - versions = await fetchVersions(dm); - localStorage.setItem('kantine_version_cache', JSON.stringify({ - timestamp: Date.now(), devMode: dm, versions - })); - } - - if (!versions.length) { + function renderVersionsList(versions) { + if (!versions || !versions.length) { container.innerHTML = 'Keine Versionen gefunden.
'; return; } @@ -2046,6 +2035,34 @@ `; list.appendChild(li); }); + } + + try { + // 1. Show cached versions immediately if available + const cachedRaw = localStorage.getItem('kantine_version_cache'); + let cached = null; + if (cachedRaw) { + try { cached = JSON.parse(cachedRaw); } catch (e) { } + } + + if (cached && cached.devMode === dm && cached.versions) { + renderVersionsList(cached.versions); + } + + // 2. Fetch fresh versions in background (or foreground if no cache) + const liveVersions = await fetchVersions(dm); + + // Compare with cache to see if we need to re-render + const liveVersionsStr = JSON.stringify(liveVersions); + const cachedVersionsStr = cached ? JSON.stringify(cached.versions) : ''; + + if (liveVersionsStr !== cachedVersionsStr) { + localStorage.setItem('kantine_version_cache', JSON.stringify({ + timestamp: Date.now(), devMode: dm, versions: liveVersions + })); + renderVersionsList(liveVersions); + } + } catch (e) { container.innerHTML = `Fehler: ${e.message}
`; } diff --git a/version.txt b/version.txt index 2f8dfc4..15c46fc 100755 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v1.4.10 +v1.4.11