Skip to content

Commit

Permalink
Merge pull request #20076 from dukenv0307/fix/19364
Browse files Browse the repository at this point in the history
Fix page not found appears for a second when user opens a thread
  • Loading branch information
marcochavezf authored Jun 5, 2023
2 parents cfbdbc7 + 5a85f7d commit f104baa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,16 @@ function getReportName(report) {
return _.map(participantsWithoutCurrentUser, (login) => getDisplayNameForParticipant(login, isMultipleParticipantReport)).join(', ');
}

/**
* Get the report for a reportID
*
* @param {String} reportID
* @returns {Object}
*/
function getReport(reportID) {
return allReports[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
}

/**
* Navigate to the details page of a given report
*
Expand Down Expand Up @@ -2179,6 +2189,7 @@ export {
getRoomWelcomeMessage,
getDisplayNamesWithTooltips,
getReportName,
getReport,
getReportIDFromLink,
getRouteFromLink,
navigateToDetailsPage,
Expand Down
10 changes: 10 additions & 0 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ function openReport(reportID, participantList = [], newReportObject = {}, parent
params.shouldRetry = false;
}

// If we open an exist report, but it is not present in Onyx yet, we should change the method to set for this report
// and we need data to be available when we navigate to the chat page
if (_.isEmpty(ReportUtils.getReport(reportID))) {
optimisticReportData.onyxMethod = Onyx.METHOD.SET;
optimisticReportData.value = {
...optimisticReportData.value,
reportID: reportID.toString(),
};
}

// If we are creating a new report, we need to add the optimistic report data and a report action
if (!_.isEmpty(newReportObject)) {
// Change the method to set for new reports because it doesn't exist yet, is faster,
Expand Down

0 comments on commit f104baa

Please sign in to comment.