Skip to content

Commit

Permalink
fix(APPLAUSE-6697021): auth2 back button double tap crash (#11309)
Browse files Browse the repository at this point in the history
* fix(APPLAUSE-6697021): auth2 back button double click crash

* undid change to ios/Podfile.lock
  • Loading branch information
iskounen authored and MounirDhahri committed Dec 18, 2024
1 parent 1d1f97e commit b04e407
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app/Scenes/Onboarding/Auth2/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions src/app/Scenes/Onboarding/Auth2/__tests__/AuthContext.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" } })

Expand Down

0 comments on commit b04e407

Please sign in to comment.