aboutsummaryrefslogtreecommitdiff
path: root/src/main/assets/scripts.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-10-12 04:51:03 +0300
committerGravatar Vitaly Takmazov2022-10-12 04:51:03 +0300
commit89c1e36e31c1cd7879b6a37723ae19960f430d97 (patch)
treec211893cc6ca6576b9d77833ee2799bb14e54bdc /src/main/assets/scripts.js
parentc290fb5df36571012d7a1e78b8b96aed6ab388ba (diff)
Events: correctly shutdown EventSource connection
Diffstat (limited to 'src/main/assets/scripts.js')
-rw-r--r--src/main/assets/scripts.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js
index 97525940..b103810d 100644
--- a/src/main/assets/scripts.js
+++ b/src/main/assets/scripts.js
@@ -105,7 +105,9 @@ function i18n(key = '', lang = undefined) {
|| key;
}
-var es, pageTitle;
+/** @type { EventSource } */
+var es;
+var pageTitle;
function initES() {
if (!('EventSource' in window)) {
@@ -782,6 +784,11 @@ ready(() => {
}
});
initES();
+ addEventListener('beforeunload', () => {
+ if (es) {
+ es.close();
+ }
+ });
embedAll();
});