Skip to content

Commit

Permalink
Merge pull request #4387 from aman-atg/aman-atg-fixInfiniteLoadingBug
Browse files Browse the repository at this point in the history
handle navigation when reportID isn't valid
  • Loading branch information
Jag96 authored Aug 5, 2021
2 parents 9fa8099 + b40dfc0 commit f4e86f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,8 @@ function fetchChatReportsByIDs(chatList, shouldRedirectIfInacessible = false) {
})
.catch((err) => {
if (err.message === CONST.REPORT.ERROR.INACCESSIBLE_REPORT) {
Growl.error(translateLocal('notFound.chatYouLookingForCannotBeFound'));
// eslint-disable-next-line no-use-before-define
navigateToConciergeChat();
handleInaccessibleReport();
}
});
}
Expand Down Expand Up @@ -1365,6 +1364,14 @@ function navigateToConciergeChat() {
Navigation.closeDrawer();
}

/**
* Handle the navigation when report is inaccessible
*/
function handleInaccessibleReport() {
Growl.error(translateLocal('notFound.chatYouLookingForCannotBeFound'));
navigateToConciergeChat();
}

export {
fetchAllReports,
fetchActions,
Expand All @@ -1389,4 +1396,5 @@ export {
getSimplifiedIOUReport,
syncChatAndIOUReports,
navigateToConciergeChat,
handleInaccessibleReport,
};
7 changes: 6 additions & 1 deletion src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React from 'react';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import _ from 'underscore';
import styles from '../../styles/styles';
import ReportView from './report/ReportView';
import ScreenWrapper from '../../components/ScreenWrapper';
import HeaderView from './HeaderView';
import Navigation from '../../libs/Navigation/Navigation';
import ROUTES from '../../ROUTES';
import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator';
import {updateCurrentlyViewedReportID} from '../../libs/actions/Report';
import {handleInaccessibleReport, updateCurrentlyViewedReportID} from '../../libs/actions/Report';
import ONYXKEYS from '../../ONYXKEYS';

const propTypes = {
Expand Down Expand Up @@ -89,6 +90,10 @@ class ReportScreen extends React.Component {
*/
storeCurrentlyViewedReport() {
const reportID = this.getReportID();
if (_.isNaN(reportID)) {
handleInaccessibleReport();
return;
}
updateCurrentlyViewedReportID(reportID);
}

Expand Down

0 comments on commit f4e86f3

Please sign in to comment.