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

fixes wrong fallback for goback in notification preference page #31287

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
14 changes: 14 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2255,6 +2255,19 @@ function navigateToDetailsPage(report) {
Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID));
}

/**
* Go back to the details page of a given report
*
* @param {Object} report
*/
function goBackToDetailsPage(report) {
if (isOneOnOneChat(report)) {
Navigation.goBack(ROUTES.PROFILE.getRoute(report.participantAccountIDs[0]));
return;
}
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID));
}

/**
* Generate a random reportID up to 53 bits aka 9,007,199,254,740,991 (Number.MAX_SAFE_INTEGER).
* There were approximately 98,000,000 reports with sequential IDs generated before we started using this approach, those make up roughly one billionth of the space for these numbers,
Expand Down Expand Up @@ -4414,6 +4427,7 @@ export {
hasSingleParticipant,
getReportRecipientAccountIDs,
isOneOnOneChat,
goBackToDetailsPage,
getTransactionReportName,
getTransactionDetails,
getTaskAssigneeChatOnyxData,
Expand Down
9 changes: 5 additions & 4 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1371,11 +1371,12 @@ function saveReportActionDraftNumberOfLines(reportID, reportActionID, numberOfLi
* @param {boolean} navigate
* @param {String} parentReportID
* @param {String} parentReportActionID
* @param {Object} report
*/
function updateNotificationPreference(reportID, previousValue, newValue, navigate, parentReportID = 0, parentReportActionID = 0) {
function updateNotificationPreference(reportID, previousValue, newValue, navigate, parentReportID = 0, parentReportActionID = 0, report = {}) {
if (previousValue === newValue) {
if (navigate) {
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(reportID));
if (navigate && report.reportID) {
ReportUtils.goBackToDetailsPage(report);
}
return;
}
Expand Down Expand Up @@ -1407,7 +1408,7 @@ function updateNotificationPreference(reportID, previousValue, newValue, navigat
}
API.write('UpdateReportNotificationPreference', {reportID, notificationPreference: newValue}, {optimisticData, failureData});
if (navigate) {
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(reportID));
ReportUtils.goBackToDetailsPage(report);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/pages/settings/Report/NotificationPreferencePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import ScreenWrapper from '@components/ScreenWrapper';
import SelectionList from '@components/SelectionList';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import compose from '@libs/compose';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import withReportOrNotFound from '@pages/home/report/withReportOrNotFound';
import reportPropTypes from '@pages/reportPropTypes';
import * as Report from '@userActions/Report';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';

const propTypes = {
...withLocalizePropTypes,
Expand Down Expand Up @@ -41,11 +39,13 @@ function NotificationPreferencePage(props) {
<FullPageNotFoundView shouldShow={shouldDisableNotificationPreferences}>
<HeaderWithBackButton
title={props.translate('notificationPreferencesPage.header')}
onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(props.report.reportID))}
onBackButtonPress={() => ReportUtils.goBackToDetailsPage(props.report)}
/>
<SelectionList
sections={[{data: notificationPreferenceOptions}]}
onSelectRow={(option) => Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, option.value, true)}
onSelectRow={(option) =>
Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, option.value, true, undefined, undefined, props.report)
}
initiallyFocusedOptionKey={_.find(notificationPreferenceOptions, (locale) => locale.isSelected).keyForList}
/>
</FullPageNotFoundView>
Expand Down
Loading