Skip to content

Commit

Permalink
fix(tab nav): fix navigating back from language selection (#5146)
Browse files Browse the repository at this point in the history
### Description

issue found in bugapalooza when changing language. Fixed so now you
don't see back arrow + hamburger when in new tab experience.

### Test plan

Manual test changing language:


https://github.com/valora-inc/wallet/assets/140328381/96c727ce-1b4a-44ff-ab89-68510fc097ad

Testing other paths:


https://github.com/valora-inc/wallet/assets/140328381/8f951b09-f204-4f8c-8f3a-977aa30ccf16


### Related issues

- N/A

### Backwards compatibility

Yes

### Network scalability

If a new NetworkId and/or Network are added in the future, the changes
in this PR will:

- N/A
  • Loading branch information
finnian0826 committed Mar 23, 2024
1 parent 73f10d5 commit 98637c3
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 40 deletions.
6 changes: 3 additions & 3 deletions src/account/Settings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ describe('Account', () => {
expect(mockFetch).toHaveBeenCalledTimes(1)
})

it('deletes the account and unlinks the phone number successfully', async () => {
it('deletes the account and unlinks the phone number successfully (using SettingsDrawer screen)', async () => {
mockedEnsurePincode.mockImplementation(() => Promise.resolve(true))
mockFetch.mockResponseOnce(JSON.stringify({ message: 'OK' }), {
status: 200,
Expand All @@ -450,7 +450,7 @@ describe('Account', () => {

const tree = render(
<Provider store={store}>
<Settings {...getMockStackScreenProps(Screens.Settings)} />
<Settings {...getMockStackScreenProps(Screens.SettingsDrawer)} />
</Provider>
)

Expand Down Expand Up @@ -482,7 +482,7 @@ describe('Account', () => {

const tree = render(
<Provider store={store}>
<Settings {...getMockStackScreenProps(Screens.Settings, { isTabNav: true })} />
<Settings {...getMockStackScreenProps(Screens.Settings)} />
</Provider>
)

Expand Down
2 changes: 1 addition & 1 deletion src/account/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const Account = ({ navigation, route }: Props) => {
const dispatch = useDispatch()
const { t } = useTranslation()
const promptConfirmRemovalModal = route.params?.promptConfirmRemovalModal
const isTabNav = route.params?.isTabNav
const isTabNav = route.name === Screens.Settings

const revokeBottomSheetRef = useRef<BottomSheetRefType>(null)
const deleteAccountBottomSheetRef = useRef<BottomSheetRefType>(null)
Expand Down
2 changes: 1 addition & 1 deletion src/account/Support.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { createMockStore, getMockStackScreenProps } from 'test/utils'
const renderSupport = () =>
render(
<Provider store={createMockStore()}>
<Support {...getMockStackScreenProps(Screens.Support)} />
<Support {...getMockStackScreenProps(Screens.SupportDrawer)} />
</Provider>
)

Expand Down
4 changes: 2 additions & 2 deletions src/account/Support.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const onPressContact = () => {
navigate(Screens.SupportContact)
}

const Support = ({ navigation, route }: Props) => {
const Support = ({ route }: Props) => {
const { t } = useTranslation()
const isTabNav = route.params?.isTabNav
const isTabNav = route.name === Screens.Support

return (
<SafeAreaView
Expand Down
3 changes: 1 addition & 2 deletions src/backup/BackupComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ function BackupComplete({ route }: Props) {
const timer = setTimeout(() => {
if (settingsScreen) {
// TODO(ACT-1133): change settingsScreen props to isAccountRemoval boolean to know if we need to go back to settings to show promptConfirmRemovalModal
navigate(settingsScreen === Screens.Settings ? Screens.Settings : Screens.SettingsDrawer, {
navigate(settingsScreen, {
promptConfirmRemovalModal: true,
isTabNav: settingsScreen === Screens.Settings,
})
} else if (backupCompleted) {
ValoraAnalytics.track(OnboardingEvents.backup_complete)
Expand Down
4 changes: 1 addition & 3 deletions src/backup/BackupQuiz.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ describe('BackupQuiz', () => {
)

fireEvent.press(getByTestId('CancelButton'))
expect(navigate).toBeCalledWith(routeParams.settingsScreen, {
isTabNav: routeParams.settingsScreen === Screens.Settings,
})
expect(navigate).toBeCalledWith(routeParams.settingsScreen)
}
)

Expand Down
12 changes: 1 addition & 11 deletions src/backup/BackupQuiz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,7 @@ export const navOptionsForQuiz = ({ route }: OwnProps) => {
...emptyHeader,
headerLeft: () => {
return settingsScreen ? (
<CancelButton
onCancel={() =>
navigate(
settingsScreen === Screens.Settings ? Screens.Settings : Screens.SettingsDrawer,
{
isTabNav: settingsScreen === Screens.Settings,
}
)
}
style={styles.cancelButton}
/>
<CancelButton onCancel={() => navigate(settingsScreen)} style={styles.cancelButton} />
) : (
<CancelConfirm screen={TAG} />
)
Expand Down
4 changes: 2 additions & 2 deletions src/navigator/ProfileMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('ProfileMenu', () => {
fireEvent.press(getByTestId('ProfileMenu/Help'))
expect(navigate).toHaveBeenCalledTimes(3)
expect(navigate).toHaveBeenNthCalledWith(1, Screens.Invite)
expect(navigate).toHaveBeenNthCalledWith(2, Screens.Settings, { isTabNav: true })
expect(navigate).toHaveBeenNthCalledWith(3, Screens.Support, { isTabNav: true })
expect(navigate).toHaveBeenNthCalledWith(2, Screens.Settings)
expect(navigate).toHaveBeenNthCalledWith(3, Screens.Support)
})
})
10 changes: 2 additions & 8 deletions src/navigator/ProfileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,13 @@ export default function ProfileMenu({ route }: Props) {
<Text style={styles.actionLabel}>{t('invite')}</Text>
</View>
</Touchable>
<Touchable
testID="ProfileMenu/Settings"
onPress={() => navigate(Screens.Settings, { isTabNav: true })}
>
<Touchable testID="ProfileMenu/Settings" onPress={() => navigate(Screens.Settings)}>
<View style={styles.container}>
<Settings color={Colors.gray3} />
<Text style={styles.actionLabel}>{t('settings')}</Text>
</View>
</Touchable>
<Touchable
testID="ProfileMenu/Help"
onPress={() => navigate(Screens.Support, { isTabNav: true })}
>
<Touchable testID="ProfileMenu/Help" onPress={() => navigate(Screens.Support)}>
<View style={styles.container}>
<Help color={Colors.gray3} />
<Text style={styles.actionLabel}>{t('help')}</Text>
Expand Down
14 changes: 7 additions & 7 deletions src/navigator/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type StackParamList = {
[Screens.BackupComplete]:
| undefined
| {
settingsScreen: Screens | undefined
settingsScreen: Screens.Settings | Screens.SettingsDrawer | undefined
}
[Screens.BackupIntroduction]:
| {
Expand All @@ -70,12 +70,12 @@ export type StackParamList = {
[Screens.BackupPhrase]:
| undefined
| {
settingsScreen: Screens | undefined
settingsScreen: Screens.Settings | Screens.SettingsDrawer | undefined
}
[Screens.BackupQuiz]:
| undefined
| {
settingsScreen: Screens | undefined
settingsScreen: Screens.Settings | Screens.SettingsDrawer | undefined
}
[Screens.FiatDetailsScreen]: {
quote: FiatConnectQuote
Expand Down Expand Up @@ -265,15 +265,15 @@ export type StackParamList = {
sendAmount: string
tokenId: string
}
[Screens.Settings]: { promptConfirmRemovalModal?: boolean; isTabNav?: boolean } | undefined
[Screens.SettingsDrawer]: { promptConfirmRemovalModal?: boolean; isTabNav?: boolean } | undefined
[Screens.Settings]: { promptConfirmRemovalModal?: boolean } | undefined
[Screens.SettingsDrawer]: { promptConfirmRemovalModal?: boolean } | undefined
[Screens.SignInWithEmail]: {
keylessBackupFlow: KeylessBackupFlow
}
[Screens.Spend]: undefined
[Screens.StoreWipeRecoveryScreen]: undefined
[Screens.Support]: { isTabNav?: boolean } | undefined
[Screens.SupportDrawer]: { isTabNav?: boolean } | undefined
[Screens.Support]: undefined
[Screens.SupportDrawer]: {} | undefined
[Screens.SupportContact]:
| {
prefilledText: string
Expand Down

0 comments on commit 98637c3

Please sign in to comment.