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

#2 - Fix multiple open report call when report screen is mounted #41427

Merged
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: 5 additions & 9 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,19 +434,12 @@ function ReportScreen({
return;
}

// It is possible that we may not have the report object yet in Onyx yet e.g. we navigated to a URL for an accessible report that
// is not stored locally yet. If report.reportID exists, then the report has been stored locally and nothing more needs to be done.
// If it doesn't exist, then we fetch the report from the API.
if (report.reportID && report.reportID === reportIDFromRoute && !reportMetadata?.isLoadingInitialReportActions) {
return;
}

if (!shouldFetchReport(report)) {
return;
}

fetchReport();
}, [report, reportMetadata?.isLoadingInitialReportActions, fetchReport, reportIDFromRoute]);
}, [report, fetchReport, reportIDFromRoute]);

const dismissBanner = useCallback(() => {
setIsBannerVisible(false);
Expand All @@ -473,7 +466,10 @@ function ReportScreen({
Timing.end(CONST.TIMING.CHAT_RENDER);
Performance.markEnd(CONST.TIMING.CHAT_RENDER);

fetchReportIfNeeded();
// Call OpenReport only if we are not linking to a message or the report is not available yet
if (!reportActionIDFromRoute || !report.reportID) {
fetchReportIfNeeded();
}
neil-marcellini marked this conversation as resolved.
Show resolved Hide resolved
const interactionTask = InteractionManager.runAfterInteractions(() => {
ComposerActions.setShouldShowComposeInput(true);
});
Expand Down
18 changes: 0 additions & 18 deletions src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,24 +243,6 @@ function ReportActionsView({
const oldestReportAction = useMemo(() => reportActions?.at(-1), [reportActions]);
const hasCreatedAction = oldestReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED;

useEffect(() => {
if (reportActionID) {
return;
}

const interactionTask = InteractionManager.runAfterInteractions(() => {
neil-marcellini marked this conversation as resolved.
Show resolved Hide resolved
openReportIfNecessary();
});
// eslint-disable-next-line @typescript-eslint/no-misused-promises
if (interactionTask) {
return () => {
interactionTask.cancel();
};
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
if (!reportActionID || indexOfLinkedAction > -1) {
return;
Expand Down
Loading