fix: fetch sparkline/chart immediately on SSE ping, no debounce delay
This commit is contained in:
@@ -265,18 +265,16 @@
|
||||
}
|
||||
});
|
||||
|
||||
// SSE: account stream filtered to this monitor — refresh chart on ping
|
||||
let _chartRefreshTimer = null;
|
||||
watchAccount((ping) => {
|
||||
if (ping.monitor_id !== monitorId) return;
|
||||
if (_chartRefreshTimer) return;
|
||||
_chartRefreshTimer = setTimeout(async () => {
|
||||
_chartRefreshTimer = null;
|
||||
try {
|
||||
const res = await fetch(`/dashboard/monitors/${monitorId}/chart`, { credentials: 'same-origin' });
|
||||
if (res.ok) document.getElementById('latency-chart').innerHTML = await res.text();
|
||||
} catch {}
|
||||
}, 5000);
|
||||
// SSE: on ping for this monitor, fetch fresh chart
|
||||
let _fetchingChart = false;
|
||||
watchAccount(async (ping) => {
|
||||
if (ping.monitor_id !== monitorId || _fetchingChart) return;
|
||||
_fetchingChart = true;
|
||||
try {
|
||||
const res = await fetch(`/dashboard/monitors/${monitorId}/chart`, { credentials: 'same-origin' });
|
||||
if (res.ok) document.getElementById('latency-chart').innerHTML = await res.text();
|
||||
} catch {}
|
||||
_fetchingChart = false;
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user