diff options
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/dashboard/dashboard.html | 11 |
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)) { |
