Skip to content
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

Ideal nav merge up #16

Merged
merged 7 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/NavigationRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
currentReportIDValue?.updateCurrentReportID(state);
}, 0);
parseAndLogRoute(state);
console.log(state);

Check failure on line 84 in src/libs/Navigation/NavigationRoot.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function setLocale(locale: Locale) {

function setLocaleAndNavigate(locale: Locale) {
setLocale(locale);
Navigation.goBack(ROUTES.SETTINGS_PREFERENCES);
Navigation.goBack();
}

function setSidebarLoaded() {
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/PersonalDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function updatePronouns(pronouns: string) {
});
}

Navigation.goBack(ROUTES.SETTINGS_PROFILE);
Navigation.goBack();
}

function updateDisplayName(firstName: string, lastName: string) {
Expand Down Expand Up @@ -183,7 +183,7 @@ function updateDisplayName(firstName: string, lastName: string) {
});
}

Navigation.goBack(ROUTES.SETTINGS_PROFILE);
Navigation.goBack();
}

function updateLegalName(legalFirstName: string, legalLastName: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/TwoFactorAuthActions.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand All @@ -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};
4 changes: 2 additions & 2 deletions src/libs/actions/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ function updateChatPriorityMode(mode, automatic = false) {
);

if (!autoSwitchedToFocusMode) {
Navigation.goBack(ROUTES.SETTINGS_PREFERENCES);
Navigation.goBack();
}
}

Expand Down Expand Up @@ -794,7 +794,7 @@ function updateTheme(theme) {
{optimisticData},
);

Navigation.navigate(ROUTES.SETTINGS_PREFERENCES);
Navigation.goBack();
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/Preferences/LanguagePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -32,7 +31,7 @@ function LanguagePage(props) {
>
<HeaderWithBackButton
title={props.translate('languagePage.language')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PREFERENCES)}
onBackButtonPress={() => Navigation.goBack()}
/>
<SelectionList
sections={[{data: localesToLanguages}]}
Expand Down
5 changes: 2 additions & 3 deletions src/pages/settings/Preferences/PriorityModePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Navigation from '@libs/Navigation/Navigation';
import * as User from '@userActions/User';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';

const propTypes = {
/** The chat priority mode */
Expand All @@ -38,7 +37,7 @@ function PriorityModePage(props) {
const updateMode = useCallback(
(mode) => {
if (mode.value === props.priorityMode) {
Navigation.navigate(ROUTES.SETTINGS_PREFERENCES);
Navigation.goBack();
return;
}
User.updateChatPriorityMode(mode.value);
Expand All @@ -53,7 +52,7 @@ function PriorityModePage(props) {
>
<HeaderWithBackButton
title={props.translate('priorityModePage.priorityMode')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PREFERENCES)}
onBackButtonPress={() => Navigation.goBack()}
/>
<Text style={[styles.mh5, styles.mv3]}>{props.translate('priorityModePage.explainerText')}</Text>
<SelectionList
Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/Preferences/ThemePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Navigation from '@libs/Navigation/Navigation';
import * as User from '@userActions/User';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';

const propTypes = {
/** The theme of the app */
Expand Down Expand Up @@ -41,7 +40,7 @@ function ThemePage(props) {
<HeaderWithBackButton
title={translate('themePage.theme')}
shouldShowBackButton
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_PREFERENCES)}
onBackButtonPress={() => Navigation.goBack()}
onCloseButtonPress={() => Navigation.dismissModal(true)}
/>

Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Profile/Contacts/ContactMethodsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Profile/CustomStatus/StatusPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/Profile/DisplayNamePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -79,7 +78,7 @@ function DisplayNamePage(props) {
>
<HeaderWithBackButton
title={props.translate('displayNamePage.headerTitle')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PROFILE)}
onBackButtonPress={() => Navigation.goBack()}
/>
{props.isLoadingApp ? (
<FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function PersonalDetailsInitialPage(props) {
<ScreenWrapper testID={PersonalDetailsInitialPage.displayName}>
<HeaderWithBackButton
title={props.translate('privatePersonalDetails.personalDetails')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PROFILE)}
onBackButtonPress={() => Navigation.goBack()}
/>
{isLoadingPersonalDetails ? (
<FullscreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />
Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/Profile/PronounsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -92,7 +91,7 @@ function PronounsPage({currentUserPersonalDetails, isLoadingApp}) {
<>
<HeaderWithBackButton
title={translate('pronounsPage.pronouns')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PROFILE)}
onBackButtonPress={() => Navigation.goBack()}
/>
<Text style={[styles.ph5, styles.mb3]}>{translate('pronounsPage.isShownOnProfile')}</Text>
<SelectionList
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Profile/TimezoneInitialPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function TimezoneInitialPage(props) {
<ScreenWrapper testID={TimezoneInitialPage.displayName}>
<HeaderWithBackButton
title={props.translate('timezonePage.timezone')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PROFILE)}
onBackButtonPress={() => Navigation.goBack()}
/>
<View style={styles.flex1}>
<View style={[styles.ph5]}>
Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/Security/CloseAccountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -91,7 +90,7 @@ function CloseAccountPage(props) {
>
<HeaderWithBackButton
title={props.translate('closeAccountPage.closeAccount')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_SECURITY)}
onBackButtonPress={() => Navigation.goBack()}
/>
<FormProvider
formID={ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM}
Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/Wallet/AddDebitCardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -107,7 +106,7 @@ function DebitCardPage(props) {
>
<HeaderWithBackButton
title={translate('addDebitCardPage.addADebitCard')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WALLET)}
onBackButtonPress={() => Navigation.goBack()}
/>
<FormProvider
formID={ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}}
/>
<SelectionList
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ function WorkspaceMembersPage(props) {
title={props.translate('workspace.common.members')}
onBackButtonPress={() => {
setSearchValue('');
Navigation.goBack(ROUTES.WORKSPACE_INITIAL.getRoute(policyID));
Navigation.goBack();
}}
shouldShowBackButton={isSmallScreenWidth}
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS}
Expand Down
5 changes: 2 additions & 3 deletions src/pages/workspace/WorkspaceNamePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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],
);
Expand Down Expand Up @@ -67,7 +66,7 @@ function WorkspaceNamePage({policy}) {
>
<HeaderWithBackButton
title={translate('workspace.editor.nameInputLabel')}
onBackButtonPress={() => Navigation.goBack(ROUTES.WORKSPACE_OVERVIEW.getRoute(policy.id))}
onBackButtonPress={() => Navigation.goBack()}
/>
<FormProvider
formID={ONYXKEYS.FORMS.WORKSPACE_SETTINGS_FORM}
Expand Down
8 changes: 3 additions & 5 deletions src/pages/workspace/WorkspaceOverviewCurrencyPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import React, {useCallback, useState} from 'react';
import React, {useState} from 'react';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
Expand Down Expand Up @@ -68,11 +68,9 @@ function WorkspaceSettingsCurrencyPage({currencyList, policy, isLoadingReportDat

const headerMessage = searchText.trim() && !currencyItems.length ? translate('common.noResultsFound') : '';

const onBackButtonPress = useCallback(() => 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 (
Expand All @@ -87,7 +85,7 @@ function WorkspaceSettingsCurrencyPage({currencyList, policy, isLoadingReportDat
>
<HeaderWithBackButton
title={translate('workspace.editor.currencyInputLabel')}
onBackButtonPress={onBackButtonPress}
onBackButtonPress={() => Navigation.goBack()}
/>

<SelectionList
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspacePageWithSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function WorkspacePageWithSections({backButtonRoute, children, footer, guidesCal
title={headerText}
guidesCallTaskID={guidesCallTaskID}
shouldShowBackButton={isSmallScreenWidth}
onBackButtonPress={() => Navigation.goBack(backButtonRoute || ROUTES.WORKSPACE_INITIAL.getRoute(policyID))}
onBackButtonPress={() => Navigation.goBack(backButtonRoute)}
shouldShowBorderBottom
/>
{shouldUseScrollView ? (
Expand Down
4 changes: 1 addition & 3 deletions src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) => {
Expand All @@ -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)}
>
{() => (
<FormProvider
Expand Down
Loading