aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-08-21 10:24:17 -0300
committerSebastian <sebasjm@gmail.com>2024-08-21 10:25:25 -0300
commit5627896757d8ff7418f0db6e50478eda521df84f (patch)
tree91ad731d684d378aa5dece61361aba659e76665f /packages
parent2aaa2e999a034f5020eb8ef4a21a8fe71d92ff74 (diff)
downloadwallet-core-5627896757d8ff7418f0db6e50478eda521df84f.tar.xz
do not require state
Diffstat (limited to 'packages')
-rw-r--r--packages/challenger-ui/src/hooks/session.ts26
1 files 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,
+ });
+ }
},
};
}