From 8f1f90c3e7d836a23f1cd09617c2a0fcfac3f3f4 Mon Sep 17 00:00:00 2001
From: Melonai <einebeere@gmail.com>
Date: Mon, 31 May 2021 01:47:38 +0200
Subject: Socket connection with managed state

---
 assets/src/components/IncomingRequests.svelte | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

(limited to 'assets/src/components/IncomingRequests.svelte')

diff --git a/assets/src/components/IncomingRequests.svelte b/assets/src/components/IncomingRequests.svelte
index 1db50af..bf08ffe 100644
--- a/assets/src/components/IncomingRequests.svelte
+++ b/assets/src/components/IncomingRequests.svelte
@@ -1,18 +1,17 @@
 <script lang="ts">
-    import { getToken, joinShareChannel } from "../network/socket";
+    import { getOwnToken, start, Type } from "../network/channel/connection";
+
     import requests from "../stores/requests";
 
-    const startConnection = async () => {
-        const token = await getToken();
-        joinShareChannel(token);
-        return token;
-    };
+    const startPromise = start(Type.SHARE);
+
+    // TODO: Switch to store-based state updates.
 </script>
 
-{#await startConnection()}
+{#await startPromise}
     <h3>Fetching token...</h3>
-{:then token}
-    <h3>Your token is <b>{token}</b>.</h3>
+{:then}
+    <h3>Your token is <b>{getOwnToken()}</b>.</h3>
 
     {#each $requests as request}
         <p>{JSON.stringify(request)}</p>
-- 
cgit 1.4.1

