diff options
author | Sebastian <sebasjm@gmail.com> | 2024-08-21 10:24:17 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-08-21 10:25:25 -0300 |
commit | 5627896757d8ff7418f0db6e50478eda521df84f (patch) | |
tree | 91ad731d684d378aa5dece61361aba659e76665f /packages | |
parent | 2aaa2e999a034f5020eb8ef4a21a8fe71d92ff74 (diff) | |
download | wallet-core-5627896757d8ff7418f0db6e50478eda521df84f.tar.xz |
do not require state
Diffstat (limited to 'packages')
-rw-r--r-- | packages/challenger-ui/src/hooks/session.ts | 26 |
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, + }); + } }, }; } |