gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 03/03: do not require state


From: gnunet
Subject: [taler-wallet-core] 03/03: do not require state
Date: Wed, 21 Aug 2024 15:25:43 +0200

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository wallet-core.

commit 5627896757d8ff7418f0db6e50478eda521df84f
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Wed Aug 21 10:24:17 2024 -0300

    do not require state
---
 packages/challenger-ui/src/hooks/session.ts | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/packages/challenger-ui/src/hooks/session.ts 
b/packages/challenger-ui/src/hooks/session.ts
index a808697ea..86dfff94e 100644
--- a/packages/challenger-ui/src/hooks/session.ts
+++ b/packages/challenger-ui/src/hooks/session.ts
@@ -102,16 +102,14 @@ export function useSessionState(): SessionStateHandler {
       });
     },
     removeAddress(index) {
-      if (!state) throw Error("should have an state");
       const lastAddr = [...(state?.lastAddress ?? [])];
       lastAddr.splice(index, 1);
       update({
-        ...state,
+        completedURL: undefined,
         lastAddress: lastAddr,
       });
     },
     saveAddress(type, address) {
-      if (!state) throw Error("should have an state");
       const lastAddr = [...(state?.lastAddress ?? [])];
       lastAddr.push({
         type,
@@ -119,24 +117,26 @@ export function useSessionState(): SessionStateHandler {
         savedAt: AbsoluteTime.now(),
       });
       update({
-        ...state,
+        completedURL: undefined,
         lastAddress: lastAddr,
       });
     },
     sent(info) {
-      if (!state) throw Error("should have an state");
-      // instead of reloading state from server we can update client state
     },
     failed(info) {
-      if (!state) throw Error("should have an state");
-      // instead of reloading state from server we can update client state
     },
     completed(info) {
-      if (!state) throw Error("should have an state");
-      update({
-        ...state,
-        completedURL: info.redirect_url,
-      });
+      if (!state) {
+        update({
+          completedURL: info.redirect_url,
+          lastAddress: [],
+        });
+      } else {
+        update({
+          completedURL: info.redirect_url,
+          lastAddress: state.lastAddress,
+        });
+      }
     },
   };
 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]