diff --git a/pkg/service/handlers/web/index.html b/pkg/service/handlers/web/index.html index b86a696..5fc93e8 100644 --- a/pkg/service/handlers/web/index.html +++ b/pkg/service/handlers/web/index.html @@ -31,6 +31,8 @@ Admin & Setup console: migration, settings, accounts, and diagnostics.

+
+
+
+ `).join(""); + } catch (error) { + console.error("Failed to fetch announcements", error); + } +} + +// dismissAnnouncement records the dismissal server-side (so it stays +// dismissed across sessions/devices — not a client-only localStorage flag) +// and removes it from the DOM immediately rather than waiting on a refetch. +async function dismissAnnouncement(id) { + try { + await fetch(`/api/announcements/${encodeURIComponent(id)}/dismiss`, {method: "POST"}); + } catch (error) { + console.error("Failed to dismiss announcement", error); + } + + const el = document.querySelector(`[data-announcement-id="${id}"]`); + if (el) el.remove(); +} + async function fetchVersion() { try { const response = await fetch("/api/setup/version"); @@ -1797,6 +1837,7 @@ function formatXML(xml) { document.addEventListener("DOMContentLoaded", async () => { const cfg = await fetchSettings(); fetchVersion(); + fetchAnnouncements(); const deviceCount = await fetchDevices(); // Only sweep automatically on a cold start (no devices known yet). When // devices are already in the store, rely on the cached list plus the