Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 8 additions & 5 deletions src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function ReportActionsList({
const readActionSkipped = useRef(false);
const hasHeaderRendered = useRef(false);
const hasFooterRendered = useRef(false);
const reportActionSize = useRef(sortedReportActions.length);
const lastVisibleActionCreatedRef = useRef(report.lastVisibleActionCreated);
const lastReadTimeRef = useRef(report.lastReadTime);

const linkedReportActionID = lodashGet(route, 'params.reportActionID', '');
Expand Down Expand Up @@ -198,15 +198,15 @@ function ReportActionsList({
}
}

if (currentUnreadMarker || reportActionSize.current === sortedReportActions.length) {
if (currentUnreadMarker || lastVisibleActionCreatedRef.current === report.lastVisibleActionCreated) {
return;
}

cacheUnreadMarkers.delete(report.reportID);
reportActionSize.current = sortedReportActions.length;
lastVisibleActionCreatedRef.current = report.lastVisibleActionCreated;
setCurrentUnreadMarker(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sortedReportActions.length, report.reportID]);
}, [report.lastVisibleActionCreated, report.reportID]);

useEffect(() => {
if (!userActiveSince.current || report.reportID !== prevReportID) {
Expand Down Expand Up @@ -339,7 +339,10 @@ function ReportActionsList({
shouldDisplay = isCurrentMessageUnread && (!nextMessage || !isMessageUnread(nextMessage, lastReadTimeRef.current));
if (shouldDisplay && !messageManuallyMarkedUnread) {
const isWithinVisibleThreshold = scrollingVerticalOffset.current < MSG_VISIBLE_THRESHOLD ? reportAction.created < userActiveSince.current : true;
shouldDisplay = reportAction.actorAccountID !== Report.getCurrentUserAccountID() && isWithinVisibleThreshold;
// Prevent displaying a new marker line when report action is of type "REPORTPREVIEW" and last actor is the current user
shouldDisplay =
(ReportActionsUtils.isReportPreviewAction(reportAction) ? !reportAction.childLastActorAccountID : reportAction.actorAccountID) !== Report.getCurrentUserAccountID() &&
isWithinVisibleThreshold;
}
if (shouldDisplay) {
cacheUnreadMarkers.set(report.reportID, reportAction.reportActionID);
Expand Down
3 changes: 2 additions & 1 deletion src/types/onyx/ReportAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ type ReportActionBase = {
childStateNum?: ValueOf<typeof CONST.REPORT.STATE_NUM>;
childLastReceiptTransactionIDs?: string;
childLastMoneyRequestComment?: string;
childLastActorAccountID?: number;
timestamp?: number;
reportActionTimestamp?: number;
childMoneyRequestCount?: number;
isFirstItem?: boolean;

/** Informations about attachments of report action */
/** Information about attachments of report action */
attachmentInfo?: (File & {source: string; uri: string}) | Record<string, never>;

/** Receipt tied to report action */
Expand Down