Skip to content

Commit

Permalink
fixes the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ishpaul777 committed Nov 13, 2023
1 parent 425ae9d commit 0a72a2e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
14 changes: 14 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2215,6 +2215,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 @@ -4323,6 +4336,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 @@ -1369,11 +1369,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 @@ -1405,7 +1406,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
6 changes: 2 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,11 @@ 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

0 comments on commit 0a72a2e

Please sign in to comment.