Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: do not display new line when creating request money. #32177

Merged
merged 9 commits into from
Dec 7, 2023
Merged
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
Loading