From c4bdcb0dd90ef955269df17bccd53e4991345777 Mon Sep 17 00:00:00 2001
From: Kit La Touche <kit@transneptune.net>
Date: Mon, 11 Nov 2024 14:24:04 -0500
Subject: Clean up event stream on window close

---
 ui/routes/(app)/+layout.svelte | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'ui/routes/(app)/+layout.svelte')

diff --git a/ui/routes/(app)/+layout.svelte b/ui/routes/(app)/+layout.svelte
index 86bc330..7e2c0e0 100644
--- a/ui/routes/(app)/+layout.svelte
+++ b/ui/routes/(app)/+layout.svelte
@@ -53,8 +53,20 @@
       events.close();
     }
   });
+
+  function beforeUnload(evt) {
+    evt.preventDefault();
+    if (events !== null) {
+      events.close();
+    }
+    // For some compat reasons?
+    evt.returnValue = '';
+    return '';
+  }
 </script>
 
+<svelte:window on:beforeunload={beforeUnload}/>
+
 <svelte:head>
   <title>pilcrow</title>
 </svelte:head>
-- 
cgit v1.2.3

