aboutsummaryrefslogtreecommitdiff
path: root/packages/challenger-ui/src/hooks
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-04-22 12:18:41 -0300
committerSebastian <sebasjm@gmail.com>2024-04-22 12:18:41 -0300
commit5db4cb99e3f16c8471117ca7443bc323180e67ec (patch)
treea2340eb33b259cf420abb6a1e3cf295c0393b4f9 /packages/challenger-ui/src/hooks
parent594dd1fd4638d658303c4c8a0f24c4082564eceb (diff)
downloadwallet-core-5db4cb99e3f16c8471117ca7443bc323180e67ec.tar.xz
fix #8393
Diffstat (limited to 'packages/challenger-ui/src/hooks')
-rw-r--r--packages/challenger-ui/src/hooks/session.ts28
1 files changed, 12 insertions, 16 deletions
diff --git a/packages/challenger-ui/src/hooks/session.ts b/packages/challenger-ui/src/hooks/session.ts
index 4d0ffeccf..ed7ea8986 100644
--- a/packages/challenger-ui/src/hooks/session.ts
+++ b/packages/challenger-ui/src/hooks/session.ts
@@ -45,9 +45,8 @@ export type LastChallengeResponse = {
};
export type SessionState = SessionId & {
- email: string | undefined;
lastTry: LastChallengeResponse | undefined;
- challengeStatus: ChallengerApi.ChallengeStatus | undefined;
+ lastStatus: ChallengerApi.ChallengeStatus | undefined;
completedURL: string | undefined;
};
export const codecForLastChallengeResponse = (): Codec<LastChallengeResponse> =>
@@ -63,15 +62,14 @@ export const codecForSessionState = (): Codec<SessionState> =>
.property("redirectURL", codecForStringURL())
.property("completedURL", codecOptional(codecForStringURL()))
.property("state", codecForString())
- .property("challengeStatus", codecOptional(codecForChallengeStatus()))
+ .property("lastStatus", codecOptional(codecForChallengeStatus()))
.property("lastTry", codecOptional(codecForLastChallengeResponse()))
- .property("email", codecOptional(codecForString()))
.build("SessionState");
export interface SessionStateHandler {
state: SessionState | undefined;
start(s: SessionId): void;
- accepted(e: string, l: LastChallengeResponse): void;
+ accepted(l: LastChallengeResponse): void;
completed(e: URL): void;
updateStatus(s: ChallengerApi.ChallengeStatus): void;
}
@@ -96,16 +94,14 @@ export function useSessionState(): SessionStateHandler {
...info,
lastTry: undefined,
completedURL: undefined,
- challengeStatus: undefined,
- email: undefined,
+ lastStatus: undefined,
});
cleanAllCache();
},
- accepted(email, lastTry) {
+ accepted(lastTry) {
if (!state) return;
update({
...state,
- email,
lastTry,
});
},
@@ -118,23 +114,23 @@ export function useSessionState(): SessionStateHandler {
},
updateStatus(st: ChallengerApi.ChallengeStatus) {
if (!state) return;
- if (!state.challengeStatus) {
+ if (!state.lastStatus) {
update({
...state,
- challengeStatus: st,
+ lastStatus: st,
});
return;
}
// current status
- const cu = state.challengeStatus;
+ const ls = state.lastStatus;
if (
- cu.changes_left !== st.changes_left ||
- cu.fix_address !== st.fix_address ||
- cu.last_address !== st.last_address
+ ls.changes_left !== st.changes_left ||
+ ls.fix_address !== st.fix_address ||
+ ls.last_address !== st.last_address
) {
update({
...state,
- challengeStatus: st,
+ lastStatus: st,
});
return;
}