From 411ba4920358aef3f221910150d926a99e34a5ae Mon Sep 17 00:00:00 2001
From: Kit La Touche <kit@transneptune.net>
Date: Wed, 23 Jul 2025 21:34:32 -0400
Subject: Wire together notifs

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

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

diff --git a/ui/routes/+layout.svelte b/ui/routes/+layout.svelte
index 0910c16..a1f8d84 100644
--- a/ui/routes/+layout.svelte
+++ b/ui/routes/+layout.svelte
@@ -6,6 +6,8 @@
   import logo from '$lib/assets/logo.png';
 
   /* ==================== Start subscription library-esque ==================== */
+  let subscriptionJson = $state(null);
+
   function doSubscribe() {
     navigator.serviceWorker.ready
       .then(async(registration) => {
@@ -23,12 +25,11 @@
           applicationServerKey: convertedVapidKey
         });
       }).then((subscription) => {
-        debugger;
-        console.debug("Subscribed", subscription.endpoint);
+        subscriptionJson = JSON.parse(JSON.stringify(subscription));
         return fetch("/api/register", {
           method: "post",
           headers: { "Content-type": "application/json" },
-          body: JSON.stringify({ subscription: subscription })
+          body: JSON.stringify(subscriptionJson),
         });
       });
   }
@@ -54,7 +55,10 @@
     fetch("/api/echo", {
       method: "post",
       headers: { "Content-type": "application/json" },
-      body: JSON.stringify({ msg: "oople doople" })
+      body: JSON.stringify({
+        ...subscriptionJson,
+        msg: "oople doople",
+      })
     });
   }
 
-- 
cgit v1.2.3

