Skip to content

Commit

Permalink
prevent double report loading
Browse files Browse the repository at this point in the history
  • Loading branch information
arosiclair committed Jun 7, 2024
1 parent 04102d9 commit 800a624
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ function ReportScreen({
const permissions = useDeepCompareRef(reportOnyx?.permissions);
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {initialValue: true});
const wasLoadingApp = usePrevious(isLoadingApp);
const prevMetadata = usePrevious(reportMetadata);
const finishedLoadingReport = prevMetadata?.isLoadingInitialReportActions && !reportMetadata?.isLoadingInitialReportActions;

/**
* Create a lightweight Report so as to keep the re-rendering as light as possible by
Expand Down Expand Up @@ -559,6 +561,11 @@ function ReportScreen({
return;
}

// If we just finished loading the report, we don't need to load it again
if (finishedLoadingReport) {
return;
}

fetchReportIfNeeded();
ComposerActions.setShouldShowComposeInput(true);
}, [
Expand All @@ -575,6 +582,7 @@ function ReportScreen({
prevReport,
reportIDFromRoute,
isFocused,
finishedLoadingReport
]);

useEffect(() => {
Expand Down

0 comments on commit 800a624

Please sign in to comment.