Skip to content
Merged
Changes from all commits
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
14 changes: 14 additions & 0 deletions src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ function ReportActionsList({
const lastVisibleActionCreatedRef = useRef(report.lastVisibleActionCreated);
const lastReadTimeRef = useRef(report.lastReadTime);

const sortedVisibleReportActions = _.filter(sortedReportActions, (s) => isOffline || s.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || s.errors);
const lastActionIndex = lodashGet(sortedVisibleReportActions, [0, 'reportActionID']);
const reportActionSize = useRef(sortedVisibleReportActions.length);

const previousLastIndex = useRef(lastActionIndex);

const linkedReportActionID = lodashGet(route, 'params.reportActionID', '');

// This state is used to force a re-render when the user manually marks a message as unread
Expand All @@ -173,6 +179,14 @@ function ReportActionsList({
opacity.value = withTiming(1, {duration: 100});
}, [opacity]);

useEffect(() => {
if (previousLastIndex.current !== lastActionIndex && reportActionSize.current > sortedVisibleReportActions.length) {
reportScrollManager.scrollToBottom();
}
previousLastIndex.current = lastActionIndex;
reportActionSize.current = sortedVisibleReportActions.length;
}, [lastActionIndex, sortedVisibleReportActions.length, reportScrollManager]);

useEffect(() => {
// If the reportID changes, we reset the userActiveSince to null, we need to do it because
// the parent component is sending the previous reportID even when the user isn't active
Expand Down