From bf1450799df0deb424a9675be89e13c29e3620d7 Mon Sep 17 00:00:00 2001
From: Mel <einebeere@gmail.com>
Date: Sat, 19 Feb 2022 20:00:38 +0100
Subject: Split state into stages to handle messages

---
 assets/src/components/request/RequestStatus.svelte | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

(limited to 'assets/src/components/request/RequestStatus.svelte')

diff --git a/assets/src/components/request/RequestStatus.svelte b/assets/src/components/request/RequestStatus.svelte
index 49a0c31..7ba93d9 100644
--- a/assets/src/components/request/RequestStatus.svelte
+++ b/assets/src/components/request/RequestStatus.svelte
@@ -1,37 +1,30 @@
 <script lang="ts">
-    import {
-        initializeRequest,
-        OwnRequestState,
-    } from "../../models/own_request";
-    import { startRequestConnection } from "../../network/channel/request_connection";
+    import { getRequestState, RequestStateType } from "../../state/request";
     import DataView from "../DataView.svelte";
 
-    const request = initializeRequest();
-    const state = request.state;
-
-    startRequestConnection(request);
+    const state = getRequestState().type;
 </script>
 
 <!-- TODO: Bind states of same path together -->
-{#if $state === OwnRequestState.PENDING || $state === OwnRequestState.ACKNOWLEDGED}
+{#if $state === RequestStateType.CONNECTING || $state === RequestStateType.WAITING_FOR_RESPONSE}
     <h1>Waiting for a response...</h1>
     <p>
-        {#if $state === OwnRequestState.ACKNOWLEDGED}
+        {#if $state === RequestStateType.CONNECTING}
             Connecting to signaling server...
         {:else}
             The share's content will become available to you once the sharer
             decides to accept your request.
         {/if}
     </p>
-{:else if $state === OwnRequestState.IN_FLIGHT || $state === OwnRequestState.DONE}
+{:else if $state === RequestStateType.IN_FLIGHT || $state === RequestStateType.DONE}
     <h1>Your request was <b>accepted!</b></h1>
-    {#if $state === OwnRequestState.IN_FLIGHT}
+    {#if $state === RequestStateType.IN_FLIGHT}
         Transferring...
     {:else}
         <p>Congratulations! You can access the received data below:</p>
         <DataView />
     {/if}
-{:else if $state === OwnRequestState.DECLINED}
+{:else if $state === RequestStateType.DECLINED}
     <h1>Your request was <b>declined!</b></h1>
     <p>Sorry! I hope we can still be friends?</p>
 {:else}
-- 
cgit 1.4.1

