Skip to content

Commit

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

This reverts commit c343552, reversing
changes made to c4d9d4e.
  • Loading branch information
francoisl committed Apr 30, 2024
1 parent 942c851 commit 159cadb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,19 @@ 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, fetchReport, reportIDFromRoute]);
}, [report, reportMetadata?.isLoadingInitialReportActions, fetchReport, reportIDFromRoute]);

const dismissBanner = useCallback(() => {
setIsBannerVisible(false);
Expand Down
18 changes: 18 additions & 0 deletions src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,24 @@ 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 159cadb

Please sign in to comment.