From b04e40748f03fac85215e33ef823ab56bbec6851 Mon Sep 17 00:00:00 2001 From: Adam Iskounen <44589599+iskounen@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:19:10 -0500 Subject: [PATCH] fix(APPLAUSE-6697021): auth2 back button double tap crash (#11309) * fix(APPLAUSE-6697021): auth2 back button double click crash * undid change to ios/Podfile.lock --- src/app/Scenes/Onboarding/Auth2/AuthContext.tsx | 4 +++- .../Onboarding/Auth2/__tests__/AuthContext.tests.tsx | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/Scenes/Onboarding/Auth2/AuthContext.tsx b/src/app/Scenes/Onboarding/Auth2/AuthContext.tsx index 54918575ad5..fc89e680a75 100644 --- a/src/app/Scenes/Onboarding/Auth2/AuthContext.tsx +++ b/src/app/Scenes/Onboarding/Auth2/AuthContext.tsx @@ -38,7 +38,9 @@ export const defaultState: AuthContextModel = { // actions goBack: action((state) => { - state.currentScreen = state.previousScreens.pop() + if (state.previousScreens.length !== 0) { + state.currentScreen = state.previousScreens.pop() + } }), setCurrentScreen: action((state, currentScreen) => { state.previousScreens.push(state.currentScreen) diff --git a/src/app/Scenes/Onboarding/Auth2/__tests__/AuthContext.tests.tsx b/src/app/Scenes/Onboarding/Auth2/__tests__/AuthContext.tests.tsx index 3783e735a20..765cfc44705 100644 --- a/src/app/Scenes/Onboarding/Auth2/__tests__/AuthContext.tests.tsx +++ b/src/app/Scenes/Onboarding/Auth2/__tests__/AuthContext.tests.tsx @@ -57,6 +57,17 @@ describe("AuthContext", () => { expect(getState().currentScreen).toEqual({ name: "SignUpPasswordStep" }) }) + it("doesn't goBack when there are no previous screens", () => { + const { getState, actions } = setup({ + currentScreen: { name: "LoginWelcomeStep" }, + previousScreens: [], + }) + + act(() => actions.goBack()) + + expect(getState().currentScreen).toEqual({ name: "LoginWelcomeStep" }) + }) + it("setCurrentScreen", () => { const { getState, actions } = setup({ currentScreen: { name: "LoginWelcomeStep" } })