aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/api/dashboard/dashboard.html27
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";