From 3c7bfedc486bae3d13de63e3c3dc1fcbe9508c77 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Thu, 12 Sep 2024 08:04:09 +0700 Subject: [PATCH 1/4] Add support for inline code with space only characters Signed-off-by: Tsaqif --- package-lock.json | 8 ++++---- package.json | 2 +- src/CONST.ts | 1 + src/libs/ReportActionsUtils.ts | 15 ++++++++++++++- src/libs/ReportUtils.ts | 4 ++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index e59d51fd3054..7ec56273857c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,7 +56,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "2.0.84", + "expensify-common": "2.0.88", "expo": "51.0.17", "expo-av": "14.0.6", "expo-image": "1.12.12", @@ -23711,9 +23711,9 @@ } }, "node_modules/expensify-common": { - "version": "2.0.84", - "resolved": "https://registry.npmjs.org/expensify-common/-/expensify-common-2.0.84.tgz", - "integrity": "sha512-VistjMexRz/1u1IqjIZwGRE7aS6QOat7420Dualn+NaqMHGkfeeB4uUR3RQhCtlDbcwFBKTryIGgSrrC0N1YpA==", + "version": "2.0.88", + "resolved": "https://registry.npmjs.org/expensify-common/-/expensify-common-2.0.88.tgz", + "integrity": "sha512-4k6X6BekydYSRWkWRMB/Ts0W5Zx3BskEpLQEuxpq+cW9QIvTyFliho/dMLaXYOqS6nMQuzkjJYqfGPx9agVnOg==", "dependencies": { "awesome-phonenumber": "^5.4.0", "classnames": "2.5.0", diff --git a/package.json b/package.json index 8777b7464521..2952ffc6c97f 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "2.0.84", + "expensify-common": "2.0.88", "expo": "51.0.17", "expo-av": "14.0.6", "expo-image": "1.12.12", diff --git a/src/CONST.ts b/src/CONST.ts index 5d248437e6f9..a4ff9ed1023b 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1004,6 +1004,7 @@ const CONST = { MAX_PREVIEW_AVATARS: 4, MAX_ROOM_NAME_LENGTH: 99, LAST_MESSAGE_TEXT_MAX_LENGTH: 200, + MIN_LENGTH_LAST_MESSAGE_WITH_ELLIPSIS: 20, OWNER_EMAIL_FAKE: '__FAKE__', OWNER_ACCOUNT_ID_FAKE: 0, DEFAULT_REPORT_NAME: 'Chat Report', diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 5a7f6602795c..90c0dd6f339b 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -739,6 +739,18 @@ function getLastVisibleAction(reportID: string, actionsToMerge: Record 0) || (trimmedMessage === '?\u2026' && lastMessageText.length > CONST.REPORT.MIN_LENGTH_LAST_MESSAGE_WITH_ELLIPSIS)) { + return ' '; + } + + return StringUtils.lineBreaksToSpaces(trimmedMessage).substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim(); +} + function getLastVisibleMessage( reportID: string, actionsToMerge: Record | null> = {}, @@ -763,7 +775,7 @@ function getLastVisibleMessage( let messageText = getReportActionMessageText(lastVisibleAction) ?? ''; if (messageText) { - messageText = StringUtils.lineBreaksToSpaces(String(messageText)).substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim(); + messageText = formatLastMessageText(messageText); } return { lastMessageText: messageText, @@ -1667,6 +1679,7 @@ function getRemovedFromApprovalChainMessage(reportAction: OnyxEntry Date: Thu, 12 Sep 2024 08:21:17 +0700 Subject: [PATCH 2/4] Modify comment Signed-off-by: Tsaqif --- src/libs/ReportActionsUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 90c0dd6f339b..9ea878617a7b 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -742,8 +742,8 @@ function getLastVisibleAction(reportID: string, actionsToMerge: Record 0) || (trimmedMessage === '?\u2026' && lastMessageText.length > CONST.REPORT.MIN_LENGTH_LAST_MESSAGE_WITH_ELLIPSIS)) { return ' '; } From d05cfc77483c42473c5027d1a3d4cd4d2086fe46 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Fri, 20 Sep 2024 10:14:40 +0700 Subject: [PATCH 3/4] fix reportactionsutils lint errors Signed-off-by: Tsaqif --- src/libs/ReportActionsUtils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 9e28f1bd128c..ef3c339de9b9 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -214,8 +214,11 @@ function isActionOfType( function getOriginalMessage(reportAction: OnyxInputOrEntry>): OriginalMessage | undefined { if (!Array.isArray(reportAction?.message)) { + // eslint-disable-next-line deprecation/deprecation return reportAction?.message ?? reportAction?.originalMessage; } + + // eslint-disable-next-line deprecation/deprecation return reportAction.originalMessage; } @@ -592,6 +595,7 @@ function isReportActionDeprecated(reportAction: OnyxEntry, key: st // HACK ALERT: We're temporarily filtering out any reportActions keyed by sequenceNumber // to prevent bugs during the migration from sequenceNumber -> reportActionID + // eslint-disable-next-line deprecation/deprecation if (String(reportAction.sequenceNumber) === key) { Log.info('Front-end filtered out reportAction keyed by sequenceNumber!', false, reportAction); return true; @@ -1709,7 +1713,7 @@ function isCardIssuedAction(reportAction: OnyxEntry) { } function getCardIssuedMessage(reportAction: OnyxEntry, shouldRenderHTML = false) { - const assigneeAccountID = (reportAction?.originalMessage as IssueNewCardOriginalMessage)?.assigneeAccountID; + const assigneeAccountID = (getOriginalMessage(reportAction) as IssueNewCardOriginalMessage)?.assigneeAccountID; const assigneeDetails = PersonalDetailsUtils.getPersonalDetailsByIDs([assigneeAccountID], currentUserAccountID ?? -1)[0]; const assignee = shouldRenderHTML ? `` : assigneeDetails?.firstName ?? assigneeDetails.login ?? ''; @@ -1766,6 +1770,7 @@ export { getNumberOfMoneyRequests, getOneTransactionThreadReportID, getOriginalMessage, + // eslint-disable-next-line deprecation/deprecation getParentReportAction, getRemovedFromApprovalChainMessage, getReportAction, From 81c3fbcbc45fc2079125515dbd9ac702fde58acd Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Fri, 20 Sep 2024 13:28:09 +0700 Subject: [PATCH 4/4] fix lints Signed-off-by: Tsaqif --- src/libs/ReportActionsUtils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index d64bd9867f03..3f6cbd50402a 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -215,11 +215,11 @@ function isActionOfType( function getOriginalMessage(reportAction: OnyxInputOrEntry>): OriginalMessage | undefined { if (!Array.isArray(reportAction?.message)) { - // eslint-disable-next-line deprecation/deprecation + // eslint-disable-next-line return reportAction?.message ?? reportAction?.originalMessage; } - // eslint-disable-next-line deprecation/deprecation + // eslint-disable-next-line return reportAction.originalMessage; } @@ -596,7 +596,7 @@ function isReportActionDeprecated(reportAction: OnyxEntry, key: st // HACK ALERT: We're temporarily filtering out any reportActions keyed by sequenceNumber // to prevent bugs during the migration from sequenceNumber -> reportActionID - // eslint-disable-next-line deprecation/deprecation + // eslint-disable-next-line if (String(reportAction.sequenceNumber) === key) { Log.info('Front-end filtered out reportAction keyed by sequenceNumber!', false, reportAction); return true; @@ -1771,7 +1771,7 @@ export { getNumberOfMoneyRequests, getOneTransactionThreadReportID, getOriginalMessage, - // eslint-disable-next-line deprecation/deprecation + // eslint-disable-next-line getParentReportAction, getRemovedFromApprovalChainMessage, getReportAction,