Skip to content

Commit bd188bb

Browse files
committed
dry-ing
1 parent 7c7d04e commit bd188bb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/libs/ReportActionsUtils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type {MessageElementBase, MessageTextElement} from './MessageElement';
3333
import * as PersonalDetailsUtils from './PersonalDetailsUtils';
3434
import type {OptimisticIOUReportAction} from './ReportUtils';
3535
import * as TransactionUtils from './TransactionUtils';
36+
import StringUtils from './StringUtils';
3637

3738
type LastVisibleMessage = {
3839
lastMessageTranslationKey?: string;
@@ -634,7 +635,7 @@ function getLastVisibleMessage(reportID: string, actionsToMerge: OnyxCollection<
634635

635636
let messageText = message?.text ?? '';
636637
if (messageText) {
637-
messageText = String(messageText).replace(CONST.REGEX.LINE_BREAK, ' ').substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim();
638+
messageText = StringUtils.lineBreaksToSpaces(String(messageText)).substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim();
638639
}
639640
return {
640641
lastMessageText: messageText,

src/libs/ReportUtils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import * as ReportActionsUtils from './ReportActionsUtils';
8181
import * as TransactionUtils from './TransactionUtils';
8282
import * as Url from './Url';
8383
import * as UserUtils from './UserUtils';
84+
import StringUtils from './StringUtils';
8485

8586
type AvatarRange = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18;
8687

@@ -1666,7 +1667,7 @@ function formatReportLastMessageText(lastMessageText: string, isModifiedExpenseM
16661667
if (isModifiedExpenseMessage) {
16671668
return String(lastMessageText).trim().replace(CONST.REGEX.LINE_BREAK, '').trim();
16681669
}
1669-
return String(lastMessageText).trim().replace(CONST.REGEX.LINE_BREAK, ' ').substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim();
1670+
return StringUtils.lineBreaksToSpaces(String(lastMessageText).trim()).substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim();
16701671
}
16711672

16721673
/**

0 commit comments

Comments
 (0)