diff --git a/frontend/components/dashboard/monitoring/MonitorPanel.tsx b/frontend/components/dashboard/monitoring/MonitorPanel.tsx index f6830645..c887410e 100644 --- a/frontend/components/dashboard/monitoring/MonitorPanel.tsx +++ b/frontend/components/dashboard/monitoring/MonitorPanel.tsx @@ -33,7 +33,7 @@ function parseRunway(html: string): RunwayPair[] { } export default function MonitorPanel() { - const [cities, setCities] = useState([]); + const [cities, setCities] = useState(null); const [time, setTime] = useState(""); const [notify, setNotify] = useState( () => typeof window !== "undefined" && localStorage.getItem("monitor_notify") !== "off" @@ -87,6 +87,11 @@ export default function MonitorPanel() { {/* Card Grid */} + {cities === null ? ( +
+ Loading… +
+ ) : (
+ )}
); } diff --git a/web/monitor_routes.py b/web/monitor_routes.py index 26a92311..a6efe7ac 100644 --- a/web/monitor_routes.py +++ b/web/monitor_routes.py @@ -118,6 +118,16 @@ def _build_cards() -> list: return cards +_cache = None +_cache_ts = 0 + + @router.get("/m/json") async def monitor_json(): - return _build_cards() + global _cache, _cache_ts + now = __import__("time").time() + if _cache is not None and now - _cache_ts < 30: + return _cache + _cache = _build_cards() + _cache_ts = now + return _cache