From 734991f9376d126e903d2ef5a1d208d1818c63f7 Mon Sep 17 00:00:00 2001 From: Adam Grzybowski Date: Thu, 21 Dec 2023 19:07:51 +0100 Subject: [PATCH 1/7] fix up for pages in workspace settings --- src/pages/workspace/WorkspaceInvitePage.js | 2 +- src/pages/workspace/WorkspaceMembersPage.js | 2 +- src/pages/workspace/WorkspaceNamePage.js | 5 ++--- src/pages/workspace/WorkspaceOverviewCurrencyPage.js | 8 +++----- src/pages/workspace/WorkspacePageWithSections.js | 2 +- src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js | 4 +--- 6 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/pages/workspace/WorkspaceInvitePage.js b/src/pages/workspace/WorkspaceInvitePage.js index 16da273750fa..6d857ba52428 100644 --- a/src/pages/workspace/WorkspaceInvitePage.js +++ b/src/pages/workspace/WorkspaceInvitePage.js @@ -252,7 +252,7 @@ function WorkspaceInvitePage(props) { guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS} onBackButtonPress={() => { Policy.clearErrors(props.route.params.policyID); - Navigation.goBack(ROUTES.WORKSPACE_MEMBERS.getRoute(props.route.params.policyID)); + Navigation.goBack(); }} /> { setSearchValue(''); - Navigation.goBack(ROUTES.WORKSPACE_INITIAL.getRoute(policyID)); + Navigation.goBack(); }} shouldShowBackButton={isSmallScreenWidth} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS} diff --git a/src/pages/workspace/WorkspaceNamePage.js b/src/pages/workspace/WorkspaceNamePage.js index 7401f0cfaaa0..1fa030f97f69 100644 --- a/src/pages/workspace/WorkspaceNamePage.js +++ b/src/pages/workspace/WorkspaceNamePage.js @@ -16,7 +16,6 @@ import * as ValidationUtils from '@libs/ValidationUtils'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; import withPolicy, {policyDefaultProps, policyPropTypes} from './withPolicy'; const propTypes = { @@ -39,7 +38,7 @@ function WorkspaceNamePage({policy}) { Policy.updateGeneralSettings(policy.id, values.name.trim(), policy.outputCurrency); Keyboard.dismiss(); - Navigation.goBack(ROUTES.WORKSPACE_OVERVIEW.getRoute(policy.id)); + Navigation.goBack(); }, [policy.id, policy.isPolicyUpdating, policy.outputCurrency], ); @@ -67,7 +66,7 @@ function WorkspaceNamePage({policy}) { > Navigation.goBack(ROUTES.WORKSPACE_OVERVIEW.getRoute(policy.id))} + onBackButtonPress={() => Navigation.goBack()} /> Navigation.goBack(ROUTES.WORKSPACE_OVERVIEW.getRoute(policy.id)), [policy.id]); - const onSelectCurrency = (item) => { Policy.updateGeneralSettings(policy.id, policy.name, item.keyForList); - Navigation.goBack(ROUTES.WORKSPACE_OVERVIEW.getRoute(policy.id)); + Navigation.goBack(); }; return ( @@ -87,7 +85,7 @@ function WorkspaceSettingsCurrencyPage({currencyList, policy, isLoadingReportDat > Navigation.goBack()} /> Navigation.goBack(backButtonRoute || ROUTES.WORKSPACE_INITIAL.getRoute(policyID))} + onBackButtonPress={() => Navigation.goBack(backButtonRoute)} shouldShowBorderBottom /> {shouldUseScrollView ? ( diff --git a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js index d17efb4dbe1e..c1e3e14bb2a3 100644 --- a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js +++ b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js @@ -23,7 +23,6 @@ import * as BankAccounts from '@userActions/BankAccounts'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; const propTypes = { ...policyPropTypes, @@ -76,7 +75,7 @@ function WorkspaceRateAndUnitPage(props) { const submit = (values) => { saveUnitAndRate(values.unit, values.rate); Keyboard.dismiss(); - Navigation.goBack(ROUTES.WORKSPACE_REIMBURSE.getRoute(props.policy.id)); + Navigation.goBack(); }; const validate = (values) => { @@ -102,7 +101,6 @@ function WorkspaceRateAndUnitPage(props) { route={props.route} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_REIMBURSE} shouldSkipVBBACall - backButtonRoute={ROUTES.WORKSPACE_REIMBURSE.getRoute(props.policy.id)} > {() => ( Date: Thu, 21 Dec 2023 19:47:39 +0100 Subject: [PATCH 2/7] fix up for pages in settings profile --- src/pages/settings/Profile/Contacts/ContactMethodsPage.js | 2 +- src/pages/settings/Profile/CustomStatus/StatusPage.js | 2 +- src/pages/settings/Profile/DisplayNamePage.js | 3 +-- .../Profile/PersonalDetails/PersonalDetailsInitialPage.js | 2 +- src/pages/settings/Profile/PronounsPage.js | 3 +-- src/pages/settings/Profile/TimezoneInitialPage.js | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pages/settings/Profile/Contacts/ContactMethodsPage.js b/src/pages/settings/Profile/Contacts/ContactMethodsPage.js index 34399daf55e3..a4119e60d860 100644 --- a/src/pages/settings/Profile/Contacts/ContactMethodsPage.js +++ b/src/pages/settings/Profile/Contacts/ContactMethodsPage.js @@ -60,7 +60,7 @@ const defaultProps = { function ContactMethodsPage(props) { const styles = useThemeStyles(); const loginNames = _.keys(props.loginList); - const navigateBackTo = lodashGet(props.route, 'params.backTo', ROUTES.SETTINGS_PROFILE); + const navigateBackTo = lodashGet(props.route, 'params.backTo', ''); // Sort the login names by placing the one corresponding to the default contact method as the first item before displaying the contact methods. // The default contact method is determined by checking against the session email (the current login). diff --git a/src/pages/settings/Profile/CustomStatus/StatusPage.js b/src/pages/settings/Profile/CustomStatus/StatusPage.js index 3c4d7b3887c0..93e9624af79c 100644 --- a/src/pages/settings/Profile/CustomStatus/StatusPage.js +++ b/src/pages/settings/Profile/CustomStatus/StatusPage.js @@ -70,7 +70,7 @@ function StatusPage({draftStatus, currentUserPersonalDetails}) { return DateUtils.isTimeAtLeastOneMinuteInFuture({dateTimeString: clearAfterTime}); }, [draftClearAfter, currentUserClearAfter]); - const navigateBackToPreviousScreen = useCallback(() => Navigation.goBack(ROUTES.SETTINGS_PROFILE, false, true), []); + const navigateBackToPreviousScreen = useCallback(() => Navigation.goBack('', false, true), []); const updateStatus = useCallback( ({emojiCode, statusText}) => { const clearAfterTime = draftClearAfter || currentUserClearAfter; diff --git a/src/pages/settings/Profile/DisplayNamePage.js b/src/pages/settings/Profile/DisplayNamePage.js index 8ea471283004..a597a0a4e751 100644 --- a/src/pages/settings/Profile/DisplayNamePage.js +++ b/src/pages/settings/Profile/DisplayNamePage.js @@ -20,7 +20,6 @@ import * as ValidationUtils from '@libs/ValidationUtils'; import * as PersonalDetails from '@userActions/PersonalDetails'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; const propTypes = { ...withLocalizePropTypes, @@ -79,7 +78,7 @@ function DisplayNamePage(props) { > Navigation.goBack(ROUTES.SETTINGS_PROFILE)} + onBackButtonPress={() => Navigation.goBack()} /> {props.isLoadingApp ? ( diff --git a/src/pages/settings/Profile/PersonalDetails/PersonalDetailsInitialPage.js b/src/pages/settings/Profile/PersonalDetails/PersonalDetailsInitialPage.js index cf6887b7e04c..41e86aa40d98 100644 --- a/src/pages/settings/Profile/PersonalDetails/PersonalDetailsInitialPage.js +++ b/src/pages/settings/Profile/PersonalDetails/PersonalDetailsInitialPage.js @@ -67,7 +67,7 @@ function PersonalDetailsInitialPage(props) { Navigation.goBack(ROUTES.SETTINGS_PROFILE)} + onBackButtonPress={() => Navigation.goBack()} /> {isLoadingPersonalDetails ? ( diff --git a/src/pages/settings/Profile/PronounsPage.js b/src/pages/settings/Profile/PronounsPage.js index 20022f22523a..5bb528373e8f 100644 --- a/src/pages/settings/Profile/PronounsPage.js +++ b/src/pages/settings/Profile/PronounsPage.js @@ -16,7 +16,6 @@ import Navigation from '@libs/Navigation/Navigation'; import * as PersonalDetails from '@userActions/PersonalDetails'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; const propTypes = { ...withCurrentUserPersonalDetailsPropTypes, @@ -92,7 +91,7 @@ function PronounsPage({currentUserPersonalDetails, isLoadingApp}) { <> Navigation.goBack(ROUTES.SETTINGS_PROFILE)} + onBackButtonPress={() => Navigation.goBack()} /> {translate('pronounsPage.isShownOnProfile')} Navigation.goBack(ROUTES.SETTINGS_PROFILE)} + onBackButtonPress={() => Navigation.goBack()} /> From 88e05167fae0dbb1c500e3379ab276cd31a74c3d Mon Sep 17 00:00:00 2001 From: Adam Grzybowski Date: Thu, 21 Dec 2023 19:47:47 +0100 Subject: [PATCH 3/7] set default fallbacRoute for goBack --- src/libs/Navigation/Navigation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index 3599833b8385..bad859d0b521 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -143,7 +143,7 @@ function navigate(route: Route = ROUTES.HOME, type?: string) { * @param shouldEnforceFallback - Enforces navigation to fallback route * @param shouldPopToTop - Should we navigate to LHN on back press */ -function goBack(fallbackRoute: Route, shouldEnforceFallback = false, shouldPopToTop = false) { +function goBack(fallbackRoute: Route = '', shouldEnforceFallback = false, shouldPopToTop = false) { if (!canNavigate('goBack')) { return; } From 29f997c317e2182b3e4ee910c265c50bb901aa36 Mon Sep 17 00:00:00 2001 From: Adam Grzybowski Date: Thu, 21 Dec 2023 20:01:06 +0100 Subject: [PATCH 4/7] fix up for pages in settings preferences --- src/libs/Navigation/NavigationRoot.tsx | 1 + src/libs/actions/App.ts | 2 +- src/libs/actions/User.js | 4 ++-- src/pages/settings/Preferences/LanguagePage.js | 3 +-- src/pages/settings/Preferences/PriorityModePage.js | 5 ++--- src/pages/settings/Preferences/ThemePage.js | 3 +-- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libs/Navigation/NavigationRoot.tsx b/src/libs/Navigation/NavigationRoot.tsx index db6703e8d446..d249c8a2aa1c 100644 --- a/src/libs/Navigation/NavigationRoot.tsx +++ b/src/libs/Navigation/NavigationRoot.tsx @@ -81,6 +81,7 @@ function NavigationRoot({authenticated, onReady}: NavigationRootProps) { currentReportIDValue?.updateCurrentReportID(state); }, 0); parseAndLogRoute(state); + console.log(state); }; return ( diff --git a/src/libs/actions/App.ts b/src/libs/actions/App.ts index ec43d4358134..8f77515fdaf1 100644 --- a/src/libs/actions/App.ts +++ b/src/libs/actions/App.ts @@ -112,7 +112,7 @@ function setLocale(locale: Locale) { function setLocaleAndNavigate(locale: Locale) { setLocale(locale); - Navigation.goBack(ROUTES.SETTINGS_PREFERENCES); + Navigation.goBack(); } function setSidebarLoaded() { diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index b1e46ec40861..e0f0f094aa5d 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -611,7 +611,7 @@ function updateChatPriorityMode(mode, automatic = false) { ); if (!autoSwitchedToFocusMode) { - Navigation.goBack(ROUTES.SETTINGS_PREFERENCES); + Navigation.goBack(); } } @@ -794,7 +794,7 @@ function updateTheme(theme) { {optimisticData}, ); - Navigation.navigate(ROUTES.SETTINGS_PREFERENCES); + Navigation.goBack(); } /** diff --git a/src/pages/settings/Preferences/LanguagePage.js b/src/pages/settings/Preferences/LanguagePage.js index 9ef95d599e97..ce93e94222b5 100644 --- a/src/pages/settings/Preferences/LanguagePage.js +++ b/src/pages/settings/Preferences/LanguagePage.js @@ -8,7 +8,6 @@ import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; import Navigation from '@libs/Navigation/Navigation'; import * as App from '@userActions/App'; import CONST from '@src/CONST'; -import ROUTES from '@src/ROUTES'; const propTypes = { ...withLocalizePropTypes, @@ -32,7 +31,7 @@ function LanguagePage(props) { > Navigation.goBack(ROUTES.SETTINGS_PREFERENCES)} + onBackButtonPress={() => Navigation.goBack()} /> { if (mode.value === props.priorityMode) { - Navigation.navigate(ROUTES.SETTINGS_PREFERENCES); + Navigation.goBack(); return; } User.updateChatPriorityMode(mode.value); @@ -53,7 +52,7 @@ function PriorityModePage(props) { > Navigation.goBack(ROUTES.SETTINGS_PREFERENCES)} + onBackButtonPress={() => Navigation.goBack()} /> {props.translate('priorityModePage.explainerText')} Navigation.navigate(ROUTES.SETTINGS_PREFERENCES)} + onBackButtonPress={() => Navigation.goBack()} onCloseButtonPress={() => Navigation.dismissModal(true)} /> From 22919157722937f8914c6abbad583034331d77f4 Mon Sep 17 00:00:00 2001 From: Adam Grzybowski Date: Thu, 21 Dec 2023 20:12:27 +0100 Subject: [PATCH 5/7] fix up for pages in settings security --- src/libs/actions/TwoFactorAuthActions.ts | 4 ++-- src/pages/settings/Security/CloseAccountPage.js | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/TwoFactorAuthActions.ts b/src/libs/actions/TwoFactorAuthActions.ts index 26e402096aa6..a260f6b69e87 100644 --- a/src/libs/actions/TwoFactorAuthActions.ts +++ b/src/libs/actions/TwoFactorAuthActions.ts @@ -1,7 +1,7 @@ import Onyx from 'react-native-onyx'; import Navigation from '@libs/Navigation/Navigation'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES, {Route} from '@src/ROUTES'; +import {Route} from '@src/ROUTES'; import {TwoFactorAuthStep} from '@src/types/onyx/Account'; /** @@ -21,7 +21,7 @@ function setCodesAreCopied() { function quitAndNavigateBack(backTo?: Route) { clearTwoFactorAuthData(); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - Navigation.goBack(backTo || ROUTES.SETTINGS_SECURITY); + Navigation.goBack(backTo || ''); } export {clearTwoFactorAuthData, setTwoFactorAuthStep, quitAndNavigateBack, setCodesAreCopied}; diff --git a/src/pages/settings/Security/CloseAccountPage.js b/src/pages/settings/Security/CloseAccountPage.js index 9aad345d7b3d..073788867aca 100644 --- a/src/pages/settings/Security/CloseAccountPage.js +++ b/src/pages/settings/Security/CloseAccountPage.js @@ -20,7 +20,6 @@ import * as CloseAccount from '@userActions/CloseAccount'; import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; const propTypes = { /** Session of currently logged in user */ @@ -91,7 +90,7 @@ function CloseAccountPage(props) { > Navigation.goBack(ROUTES.SETTINGS_SECURITY)} + onBackButtonPress={() => Navigation.goBack()} /> Date: Thu, 21 Dec 2023 20:20:05 +0100 Subject: [PATCH 6/7] fix up for pages in settings wallet --- src/pages/settings/Wallet/AddDebitCardPage.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/settings/Wallet/AddDebitCardPage.js b/src/pages/settings/Wallet/AddDebitCardPage.js index 0704bf6bf3b8..0c5cef489517 100644 --- a/src/pages/settings/Wallet/AddDebitCardPage.js +++ b/src/pages/settings/Wallet/AddDebitCardPage.js @@ -20,7 +20,6 @@ import * as ValidationUtils from '@libs/ValidationUtils'; import * as PaymentMethods from '@userActions/PaymentMethods'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; const propTypes = { /* Onyx Props */ @@ -107,7 +106,7 @@ function DebitCardPage(props) { > Navigation.goBack(ROUTES.SETTINGS_WALLET)} + onBackButtonPress={() => Navigation.goBack()} /> Date: Thu, 21 Dec 2023 20:21:58 +0100 Subject: [PATCH 7/7] fix up for pages in settings profile v2 --- src/libs/actions/PersonalDetails.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/PersonalDetails.ts b/src/libs/actions/PersonalDetails.ts index 02b5f70db285..dd7ffc7130e8 100644 --- a/src/libs/actions/PersonalDetails.ts +++ b/src/libs/actions/PersonalDetails.ts @@ -151,7 +151,7 @@ function updatePronouns(pronouns: string) { }); } - Navigation.goBack(ROUTES.SETTINGS_PROFILE); + Navigation.goBack(); } function updateDisplayName(firstName: string, lastName: string) { @@ -183,7 +183,7 @@ function updateDisplayName(firstName: string, lastName: string) { }); } - Navigation.goBack(ROUTES.SETTINGS_PROFILE); + Navigation.goBack(); } function updateLegalName(legalFirstName: string, legalLastName: string) {