-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add support for inline code with space only characters #49038
Changes from all commits
3c7bfed
102455a
3c12da6
d05cfc7
6885f11
81c3fbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,8 +215,11 @@ function isActionOfType<T extends ReportActionName[]>( | |
|
||
function getOriginalMessage<T extends ReportActionName>(reportAction: OnyxInputOrEntry<ReportAction<T>>): OriginalMessage<T> | undefined { | ||
if (!Array.isArray(reportAction?.message)) { | ||
// eslint-disable-next-line | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Previously, I was using Therefore, I am now using |
||
return reportAction?.message ?? reportAction?.originalMessage; | ||
} | ||
|
||
// eslint-disable-next-line | ||
return reportAction.originalMessage; | ||
} | ||
|
||
|
@@ -593,6 +596,7 @@ function isReportActionDeprecated(reportAction: OnyxEntry<ReportAction>, 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
if (String(reportAction.sequenceNumber) === key) { | ||
Log.info('Front-end filtered out reportAction keyed by sequenceNumber!', false, reportAction); | ||
return true; | ||
|
@@ -753,6 +757,18 @@ function getLastVisibleAction(reportID: string, actionsToMerge: Record<string, N | |
return sortedReportActions[0]; | ||
} | ||
|
||
function formatLastMessageText(lastMessageText: string) { | ||
const trimmedMessage = String(lastMessageText).trim(); | ||
|
||
// Add support for inline code containing only space characters | ||
// The message will appear as a blank space in the LHN | ||
if ((trimmedMessage === '' && lastMessageText.length > 0) || (trimmedMessage === '?\u2026' && lastMessageText.length > CONST.REPORT.MIN_LENGTH_LAST_MESSAGE_WITH_ELLIPSIS)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you share what are contexts that the second condition would be used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To test: try sending an inline code with many spaces inside it, for example:
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation. |
||
return ' '; | ||
} | ||
|
||
return StringUtils.lineBreaksToSpaces(trimmedMessage).substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim(); | ||
} | ||
|
||
function getLastVisibleMessage( | ||
reportID: string, | ||
actionsToMerge: Record<string, NullishDeep<ReportAction> | null> = {}, | ||
|
@@ -777,7 +793,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, | ||
|
@@ -1698,7 +1714,7 @@ function isCardIssuedAction(reportAction: OnyxEntry<ReportAction>) { | |
} | ||
|
||
function getCardIssuedMessage(reportAction: OnyxEntry<ReportAction>, 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 ? `<mention-user accountID="${assigneeAccountID}"/>` : assigneeDetails?.firstName ?? assigneeDetails.login ?? ''; | ||
|
@@ -1732,6 +1748,7 @@ function getCardIssuedMessage(reportAction: OnyxEntry<ReportAction>, shouldRende | |
export { | ||
doesReportHaveVisibleActions, | ||
extractLinksFromMessageHtml, | ||
formatLastMessageText, | ||
getActionableMentionWhisperMessage, | ||
getAllReportActions, | ||
getCombinedReportActions, | ||
|
@@ -1754,6 +1771,7 @@ export { | |
getNumberOfMoneyRequests, | ||
getOneTransactionThreadReportID, | ||
getOriginalMessage, | ||
// eslint-disable-next-line | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you double check if we need this disabled line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hoangzinh Yes, we need this. Removing this line will cause errors when I run |
||
getParentReportAction, | ||
getRemovedFromApprovalChainMessage, | ||
getReportAction, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double-check, are you available to check if there are no breaking changes when we bump from 2.0.84 to 2.0.88?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there are no breaking changes. However, I have noticed another issue that also wants updating the
expensify-common
package (to version 2.0.87): #46117. Should we wait for a PR to be raised for that issue? or should we proceed with this PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should. @deetergp what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've asked them in that PR if they want us to wait or not.