From 5db4cb99e3f16c8471117ca7443bc323180e67ec Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 22 Apr 2024 12:18:41 -0300 Subject: fix #8393 --- packages/challenger-ui/src/hooks/session.ts | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'packages/challenger-ui/src/hooks') 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 => @@ -63,15 +62,14 @@ export const codecForSessionState = (): Codec => .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; } -- cgit v1.2.3