Skip to content

Commit

Permalink
Merge pull request #28273 from BhuvaneshPatil/28011-add-proper-go-back
Browse files Browse the repository at this point in the history
fix: add proper fallback route for private notes pages
  • Loading branch information
techievivek authored Oct 2, 2023
2 parents 7172a7e + 7077466 commit b5dda00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/pages/PrivateNotes/PrivateNotesEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function PrivateNotesEditPage({route, personalDetailsList, session, report}) {
Keyboard.dismiss();

// Take user back to the PrivateNotesView page
Navigation.goBack(ROUTES.HOME);
Navigation.goBack(ROUTES.PRIVATE_NOTES_VIEW.getRoute(report.reportID, route.params.accountID));
};

return (
Expand All @@ -114,6 +114,7 @@ function PrivateNotesEditPage({route, personalDetailsList, session, report}) {
<HeaderWithBackButton
title={translate('privateNotes.title')}
subtitle={translate('privateNotes.myNote')}
onBackButtonPress={() => Navigation.goBack(ROUTES.PRIVATE_NOTES_VIEW.getRoute(report.repotID, route.params.accountID))}
shouldShowBackButton
onCloseButtonPress={() => Navigation.dismissModal()}
/>
Expand Down
11 changes: 11 additions & 0 deletions src/pages/PrivateNotes/PrivateNotesViewPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ function PrivateNotesViewPage({route, personalDetailsList, session, report}) {
const isCurrentUserNote = Number(session.accountID) === Number(route.params.accountID);
const privateNote = lodashGet(report, ['privateNotes', route.params.accountID, 'note'], '');

const getFallbackRoute = () => {
const privateNotes = lodashGet(report, 'privateNotes', {});

if (_.keys(privateNotes).length === 1) {
return ROUTES.HOME;
}

return ROUTES.PRIVATE_NOTES_LIST.getRoute(report.reportID);
};

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand All @@ -67,6 +77,7 @@ function PrivateNotesViewPage({route, personalDetailsList, session, report}) {
>
<HeaderWithBackButton
title={translate('privateNotes.title')}
onBackButtonPress={() => Navigation.goBack(getFallbackRoute())}
subtitle={isCurrentUserNote ? translate('privateNotes.myNote') : `${lodashGet(personalDetailsList, [route.params.accountID, 'login'], '')} note`}
shouldShowBackButton
onCloseButtonPress={() => Navigation.dismissModal()}
Expand Down

0 comments on commit b5dda00

Please sign in to comment.