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 1 commit
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
13 changes: 5 additions & 8 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,19 +426,12 @@
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]);

Check warning on line 434 in src/pages/home/ReportScreen.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint

React Hook useCallback has an unnecessary dependency: 'reportMetadata.isLoadingInitialReportActions'. Either exclude it or remove the dependency array

const dismissBanner = useCallback(() => {
setIsBannerVisible(false);
Expand All @@ -465,7 +458,11 @@
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 @@ -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(() => {
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