aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-05 01:59:21 +0100
committertv <tv@krebsco.de>2026-11-05 01:59:21 +0100
commitac6396a9068f8ab223dca05bce3b1173c61deeaa (patch)
tree4b5d1f9a55db9d0c1dcf9d44447872b6e6e94611 /src/api
parentbef410759df8ebe2fd57aa4f987103e28bb4ea97 (diff)
dashboard: ignore traffic while suspended
Diffstat (limited to 'src/api')
-rw-r--r--src/api/dashboard/dashboard.html11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/api/dashboard/dashboard.html b/src/api/dashboard/dashboard.html
index 8ee1ee5..a5a96e8 100644
--- a/src/api/dashboard/dashboard.html
+++ b/src/api/dashboard/dashboard.html
@@ -2005,6 +2005,9 @@ flowsToggle.addEventListener("click", () => {
}
});
let lastTraffic = null;
+// When the last update's traffic came, by the wall clock (it runs on while the computer
+// sleeps, unlike `performance.now()` on some systems).
+let lastTrafficAt = 0;
const flows = [];
let flowFrame = null;
// Messages and bytes by kind, of a peer's `traffic.sent` or `.received`.
@@ -2081,7 +2084,13 @@ function dotsFor(kinds, total) {
function trafficArrived() {
if (!state) return;
const self = state.node.id, now = performance.now();
- const dots = flowsShown && !calm.matches && !document.hidden &&
+ // Only for an update in its time: not the first after a gap (the computer slept, the
+ // stream stalled), whose counts grew over all of it, nor those queued meanwhile and
+ // arriving at once with it, each of which would add its dots to the same 2 s.
+ const wall = Date.now(), gap = wall - lastTrafficAt;
+ lastTrafficAt = wall;
+ const timely = gap >= FLOW_SPREAD_MS / 4 && gap <= FLOW_SPREAD_MS * 2.5;
+ const dots = timely && flowsShown && !calm.matches && !document.hidden &&
!document.getElementById("map").classList.contains("collapsed");
const current = new Map();
for (const [id, peer] of Object.entries(state.peers.peers)) {