Skip to content

Commit

Permalink
hide loading indicator when delete
Browse files Browse the repository at this point in the history
  • Loading branch information
perunt committed Jan 24, 2024
1 parent f5f2327 commit c3d93ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ function ReportActionsList({
const previousLastIndex = useRef(lastActionIndex);

const linkedReportActionID = lodashGet(route, 'params.reportActionID', '');
const isLastPendingActionIsAdd = lodashGet(sortedVisibleReportActions, [0, 'pendingAction']) === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD;
const lastPendingAction = lodashGet(sortedReportActions, [0, 'pendingAction'])
const isLastPendingActionIsAdd = lastPendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD;
const isLastPendingActionIsDelete = lastPendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;

// This is utilized for automatically scrolling to the bottom when sending a new message, in cases where comment linking is used and the user is already at the end of the list.
const isNewestActionAvailableAndPendingAdd = linkedReportActionID && isLastPendingActionIsAdd;
Expand Down Expand Up @@ -516,10 +518,13 @@ function ReportActionsList({
);
}, [isLoadingNewerReportActions, isOffline]);

// When performing comment linking, initially 25 items are added to the list. Subsequent fetches add 15 items from the cache or 50 items from the server.
// This is to ensure that the user is able to see the 'scroll to newer comments' button when they do comment linking and have not reached the end of the list yet.
const canScrollToNewerComments = !isLoadingInitialReportActions && !hasNewestReportAction && sortedReportActions.length > 25 && !isLastPendingActionIsDelete;
return (
<>
<FloatingMessageCounter
isActive={(isFloatingMessageCounterVisible && !!currentUnreadMarker) || (!isLoadingInitialReportActions && !hasNewestReportAction)}
isActive={(isFloatingMessageCounterVisible && !!currentUnreadMarker) || canScrollToNewerComments}
onClick={scrollToBottomAndMarkReportAsRead}
/>
<Animated.View style={[animatedStyles, styles.flex1, !shouldShowReportRecipientLocalTime && !hideComposer ? styles.pb4 : {}]}>
Expand Down
8 changes: 7 additions & 1 deletion src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,12 @@ function ReportActionsView({reportActions: allReportActions, ...props}) {
const loadNewerChats = useCallback(
// eslint-disable-next-line rulesdir/prefer-early-return
() => {
if (props.isLoadingInitialReportActions || props.isLoadingOlderReportActions || props.network.isOffline) {
if (
props.isLoadingInitialReportActions ||
props.isLoadingOlderReportActions ||
props.network.isOffline ||
newestReportAction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE
) {
return;
}
// Determines if loading older reports is necessary when the content is smaller than the list
Expand All @@ -362,6 +367,7 @@ function ReportActionsView({reportActions: allReportActions, ...props}) {
firstReportActionID,
props.network.isOffline,
reportActions.length,
newestReportAction,
],
);

Expand Down

0 comments on commit c3d93ea

Please sign in to comment.