Skip to content

Commit

Permalink
Fix newer messages not loading after comment linking
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis committed Aug 1, 2024
1 parent af379f6 commit b010315
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import useInitialValue from '@hooks/useInitialValue';
import useNetwork from '@hooks/useNetwork';
import usePrevious from '@hooks/usePrevious';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useWindowDimensions from '@hooks/useWindowDimensions';
import DateUtils from '@libs/DateUtils';
import getIsReportFullyVisible from '@libs/getIsReportFullyVisible';
import type {AuthScreensParamList} from '@libs/Navigation/types';
Expand Down Expand Up @@ -79,9 +78,6 @@ type ReportActionsViewProps = ReportActionsViewOnyxProps & {
transactionThreadReportID?: string | null;
};

const DIFF_BETWEEN_SCREEN_HEIGHT_AND_LIST = 120;
const SPACER = 16;

let listOldID = Math.round(Math.random() * 100);

function ReportActionsView({
Expand Down Expand Up @@ -114,7 +110,6 @@ function ReportActionsView({
const isFirstLinkedActionRender = useRef(true);

const network = useNetwork();
const {windowHeight} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const contentListHeight = useRef(0);
const isFocused = useIsFocused();
Expand Down Expand Up @@ -342,8 +337,6 @@ function ReportActionsView({
contentListHeight.current = h;
}, []);

const checkIfContentSmallerThanList = useCallback(() => windowHeight - DIFF_BETWEEN_SCREEN_HEIGHT_AND_LIST - SPACER > contentListHeight.current, [windowHeight]);

/**
* Retrieves the next set of report actions for the chat once we are nearing the end of what we are currently
* displaying.
Expand Down Expand Up @@ -397,10 +390,6 @@ function ReportActionsView({

const loadNewerChats = useCallback(
(force = false) => {
// Determines if loading older reports is necessary when the content is smaller than the list
// and there are fewer than 23 items, indicating we've reached the oldest message.
const isLoadingOlderReportsFirstNeeded = checkIfContentSmallerThanList() && reportActions.length > 23;

if (
!force &&
(!reportActionID ||
Expand All @@ -417,18 +406,16 @@ function ReportActionsView({

didLoadNewerChats.current = true;

if ((reportActionID && indexOfLinkedAction > -1 && !isLoadingOlderReportsFirstNeeded) || (!reportActionID && !isLoadingOlderReportsFirstNeeded)) {
if ((reportActionID && indexOfLinkedAction > -1) || !reportActionID) {
handleReportActionPagination({firstReportActionID: newestReportAction?.reportActionID});
}
},
[
isLoadingInitialReportActions,
isLoadingNewerReportActions,
checkIfContentSmallerThanList,
reportActionID,
indexOfLinkedAction,
handleReportActionPagination,
reportActions.length,
newestReportAction,
isFocused,
hasLoadingNewerReportActionsError,
Expand Down

0 comments on commit b010315

Please sign in to comment.