Skip to content

Commit

Permalink
Merge pull request #32177 from teneeto/fix/29376-do-not-display-new-l…
Browse files Browse the repository at this point in the history
…ine-when-creating-request-money

Fix: do not display new line when creating request money.
  • Loading branch information
MonilBhavsar authored Dec 7, 2023
2 parents 43b1722 + d82f0c8 commit 2fd1bb8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 2fd1bb8

Please sign in to comment.