Skip to content

Commit

Permalink
Merge pull request #30572 from saranshbalyan-1234/remove-openreport-a…
Browse files Browse the repository at this point in the history
…pi-call

Remove openreport api calls while switching windows
  • Loading branch information
marcaaron authored Oct 31, 2023
2 parents 09a2000 + 84a9ab6 commit 5b5d465
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {useFocusEffect} from '@react-navigation/native';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
Expand All @@ -20,12 +19,10 @@ import useLocalize from '@hooks/useLocalize';
import usePrevious from '@hooks/usePrevious';
import useWindowDimensions from '@hooks/useWindowDimensions';
import compose from '@libs/compose';
import getIsReportFullyVisible from '@libs/getIsReportFullyVisible';
import Navigation from '@libs/Navigation/Navigation';
import reportWithoutHasDraftSelector from '@libs/OnyxSelectors/reportWithoutHasDraftSelector';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import Visibility from '@libs/Visibility';
import personalDetailsPropType from '@pages/personalDetailsPropType';
import reportMetadataPropTypes from '@pages/reportMetadataPropTypes';
import reportPropTypes from '@pages/reportPropTypes';
Expand Down Expand Up @@ -276,25 +273,6 @@ function ReportScreen({
[route],
);

useFocusEffect(
useCallback(() => {
const unsubscribeVisibilityListener = Visibility.onVisibilityChange(() => {
const isTopMostReportID = Navigation.getTopmostReportId() === getReportID(route);
// If the report is not fully visible (AKA on small screen devices and LHR is open) or the report is optimistic (AKA not yet created)
// we don't need to call openReport
if (!getIsReportFullyVisible(isTopMostReportID) || report.isOptimisticReport) {
return;
}

Report.openReport(report.reportID);
});

return () => unsubscribeVisibilityListener();
// The effect should run only on the first focus to attach listener
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []),
);

useEffect(() => {
fetchReportIfNeeded();
ComposerActions.setShouldShowComposeInput(true);
Expand Down

0 comments on commit 5b5d465

Please sign in to comment.