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

Implement backTo param for ProfilePage navigation #25658

Merged
merged 1 commit into from
Aug 23, 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
5 changes: 4 additions & 1 deletion src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ export default {
DETAILS: 'details',
getDetailsRoute: (login) => `details?login=${encodeURIComponent(login)}`,
PROFILE: 'a/:accountID',
getProfileRoute: (accountID) => `a/${accountID}`,
getProfileRoute: (accountID, backTo = '') => {
const backToParam = backTo ? `?backTo=${encodeURIComponent(backTo)}` : '';
return `a/${accountID}${backToParam}`;
},
REPORT_PARTICIPANTS: 'r/:reportID/participants',
getReportParticipantsRoute: (reportID) => `r/${reportID}/participants`,
REPORT_WITH_ID_DETAILS: 'r/:reportID/details',
Expand Down
4 changes: 3 additions & 1 deletion src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ function MoneyRequestConfirmationList(props) {
*/
const navigateToReportOrUserDetail = (option) => {
if (option.accountID) {
Navigation.navigate(ROUTES.getProfileRoute(option.accountID));
const activeRoute = Navigation.getActiveRoute().replace(/\?.*/, '');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: Extra blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Should i remove the line and push it to this branch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, it's ok, it's not really significant enough to warrant follow up changes - just general feedback on newline usage 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! I'll do better next time

Navigation.navigate(ROUTES.getProfileRoute(option.accountID, activeRoute));
} else if (option.reportID) {
Navigation.navigate(ROUTES.getReportDetailsRoute(option.reportID));
}
Expand Down
5 changes: 3 additions & 2 deletions src/pages/ProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator
import BlockingView from '../components/BlockingViews/BlockingView';
import * as Illustrations from '../components/Icon/Illustrations';
import variables from '../styles/variables';
import ROUTES from '../ROUTES';
import * as ValidationUtils from '../libs/ValidationUtils';
import Permissions from '../libs/Permissions';

Expand Down Expand Up @@ -139,11 +138,13 @@ function ProfilePage(props) {
const hasStatus = !!statusEmojiCode && Permissions.canUseCustomStatus(props.betas);
const statusContent = `${statusEmojiCode} ${statusText}`;

const navigateBackTo = lodashGet(props.route, 'params.backTo', '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: Extra blank line above this


return (
<ScreenWrapper>
<HeaderWithBackButton
title={props.translate('common.profile')}
onBackButtonPress={() => Navigation.goBack(ROUTES.HOME)}
onBackButtonPress={() => Navigation.goBack(navigateBackTo)}
/>
<View
pointerEvents="box-none"
Expand Down