diff --git a/src/app/alerts/[id]/AlertDetail.tsx b/src/app/alerts/[id]/AlertDetail.tsx index 4476ab1..ef9dbe5 100644 --- a/src/app/alerts/[id]/AlertDetail.tsx +++ b/src/app/alerts/[id]/AlertDetail.tsx @@ -127,7 +127,20 @@ export default function AlertDetail({ initialAlert }: { initialAlert: Alert }) { body: JSON.stringify({ status: newStatus }), }); if (!res.ok) throw new Error(`HTTP ${res.status}`); - setAlert(await res.json()); + const updated: Alert = await res.json(); + setAlert(updated); + + // Keep the cached dashboard count in sync so the badge and summary + // card reflect the change immediately when navigating back. + try { + const raw = localStorage.getItem("oversnitch_stats"); + if (raw) { + const stats = JSON.parse(raw); + const delta = updated.status === "open" ? 1 : -1; + stats.summary.openAlertCount = Math.max(0, (stats.summary.openAlertCount ?? 0) + delta); + localStorage.setItem("oversnitch_stats", JSON.stringify(stats)); + } + } catch {} } catch (e) { setError(e instanceof Error ? e.message : String(e)); } finally {