Skip to content

Commit

Permalink
Merge pull request #40624 from bernhardoj/fix/39673-prevent-multiple-…
Browse files Browse the repository at this point in the history
…open-report

Fix multiple open report call when report screen is mounted
  • Loading branch information
flodnv authored Apr 29, 2024
2 parents c4d9d4e + 257c1de commit c343552
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
9 changes: 1 addition & 8 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,19 +426,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 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 @@ -237,24 +237,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(() => {
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

0 comments on commit c343552

Please sign in to comment.