Repository navigation
Migrate First verify-account Route (BATCH-5) #81413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
51e1ef7
3546a82
962c1d5
fc957d2
8fb4c10
177d5b5
9007535
656851e
367ade2
2671fd8
74dd154
e597284
cb16295
f13fbc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,11 +3,13 @@ import type {NavigationState, PartialState} from '@react-navigation/routers'; | |
| import {linkingConfig} from '@libs/Navigation/linkingConfig'; | ||
| import {normalizedConfigs} from '@libs/Navigation/linkingConfig/config'; | ||
| import {DYNAMIC_ROUTES} from '@src/ROUTES'; | ||
| import type {DynamicRouteSuffix} from '@src/ROUTES'; | ||
| import type {Screen} from '@src/SCREENS'; | ||
|
|
||
| type State = NavigationState | Omit<PartialState<NavigationState>, 'stale'>; | ||
|
|
||
| const dynamicRouteEntries = Object.values(DYNAMIC_ROUTES); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Do you think using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Switching to a |
||
| const dynamicRoutePaths = new Set(dynamicRouteEntries.map(({path}) => path)); | ||
|
|
||
| /** | ||
| * Checks if a screen name is a dynamic route screen | ||
|
|
@@ -19,12 +21,7 @@ function isDynamicRouteScreen(screenName: Screen): boolean { | |
| return false; | ||
| } | ||
|
|
||
| for (const {path} of dynamicRouteEntries) { | ||
| if (screenPath === path) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| return dynamicRoutePaths.has(screenPath as DynamicRouteSuffix); | ||
| } | ||
|
|
||
| const getPathFromState = (state: State): string => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| * and the second element is the query string (if any). | ||
| */ | ||
| function splitPathAndQuery(fullPath: string | undefined): [string | undefined, string | undefined] { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's best we add some unit tests for the same.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see the tests are added in the next PR #81859 (review) |
||
| const [path, query] = fullPath?.split('?') ?? [undefined, undefined]; | ||
| const [path, query] = fullPath?.split('?', 2) ?? [undefined, undefined]; | ||
| const normalizedPath = path?.endsWith('/') && path.length > 1 ? path.slice(0, -1) : path; | ||
| return [normalizedPath, query]; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: I am not sure if the paths in our App have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe we use |
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,16 @@ | ||
| import React from 'react'; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to add a new page prefixing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, that's a great way to clearly distinguish between static and dynamic pages, I’ll update the documentation to include this context. As a follow-up I’m also planning to add an ESLint rule to help validate these naming conventions for dynamic screens and components 😄 |
||
| import useDynamicBackPath from '@hooks/useDynamicBackPath'; | ||
| import {DYNAMIC_ROUTES} from '@src/ROUTES'; | ||
| import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES'; | ||
| import VerifyAccountPageBase from './VerifyAccountPageBase'; | ||
|
|
||
| function DynamicVerifyAccountPage() { | ||
| const backPath = useDynamicBackPath(DYNAMIC_ROUTES.VERIFY_ACCOUNT.path); | ||
| // currently, the default behavior of this component after completing verification is to navigate back | ||
| const forwardPath = backPath; | ||
|
|
||
| let forwardPath = backPath; | ||
| if (backPath === ROUTES.SETTINGS_WALLET) { | ||
| forwardPath = ROUTES.SETTINGS_ENABLE_PAYMENTS; | ||
|
collectioneur marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| return ( | ||
| <VerifyAccountPageBase | ||
| navigateBackTo={backPath} | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: We changed the error to
warnand now returning''. Are we sure it won't cause regression elsewhere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be safe from regressions. Since we verify that the path exists before calling this function, that
ifstatement is effectively unreachable. It was added primarily to satisfy TypeScript/ESLint requirements