diff options
| author | tv <tv@krebsco.de> | 2026-10-31 06:49:36 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 06:49:36 +0100 |
| commit | cd848f2a502a0b06e0a420d5575adbf68ded9ab1 (patch) | |
| tree | a08f0c7ffd3d654aa2fc12017911a8b5209f4923 /src | |
| parent | d3e5891d0549905065e82b95445043cd25999aec (diff) | |
dashboard: suspend when not visible
Diffstat (limited to 'src')
| -rw-r--r-- | src/api/dashboard/dashboard.html | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/api/dashboard/dashboard.html b/src/api/dashboard/dashboard.html index 1a11a25..03fa177 100644 --- a/src/api/dashboard/dashboard.html +++ b/src/api/dashboard/dashboard.html @@ -1230,6 +1230,33 @@ function connect() { }); } connect(); +// A page not shown (another tab, a minimised window) is paused: hidden for a while, it +// closes its stream, so the node stops building updates and asking members for their +// links for it; shown again, it reconnects. Briefly hidden, nothing changes. +const PAUSE_AFTER = 30000; +let paused = false; +let pausing = null; +document.addEventListener("visibilitychange", () => { + if (document.hidden) { + pausing = setTimeout(() => { + pausing = null; + paused = true; + clearTimeout(retry); + retry = null; + if (events) events.close(); + live = false; + status("paused while hidden", false); + }, PAUSE_AFTER); + } else { + clearTimeout(pausing); + pausing = null; + if (paused) { + paused = false; + status("reconnecting…", false); + connect(); + } + } +}); // A click on the status: live, everything now (a tick on the node, the members asked // again, what's open of the document read again); otherwise, reconnecting now. connection.title = "Click to refresh now"; |
