diff --git a/lib/shared/message-utils.js b/lib/shared/message-utils.js --- a/lib/shared/message-utils.js +++ b/lib/shared/message-utils.js @@ -93,9 +93,12 @@ }); } -function robotextToRawString(robotext: string | EntityText): string { +function robotextToRawString( + robotext: string | EntityText, + threadID?: string, +): string { if (typeof robotext !== 'string') { - return entityTextToRawString(robotext); + return entityTextToRawString(robotext, threadID); } return decodeURI(robotext.replace(/<([^<>|]+)\|[^<>|]+>/g, '$1')); } diff --git a/lib/utils/entity-text.js b/lib/utils/entity-text.js --- a/lib/utils/entity-text.js +++ b/lib/utils/entity-text.js @@ -189,7 +189,10 @@ return `${input.str}’s`; } -function getNameForThreadEntity(entity: ThreadEntity): string { +function getNameForThreadEntity( + entity: ThreadEntity, + threadID: ?string, +): string { const { name: userGeneratedName, display } = entity; if (entity.display === 'uiName') { return userGeneratedName ? userGeneratedName : entity.uiName; @@ -202,7 +205,10 @@ let name = userGeneratedName; if (!name || entity.alwaysDisplayShortName) { const threadType = entity.threadType ?? threadTypes.PERSONAL; - name = `this ${threadNoun(threadType)}`; + name = threadNoun(threadType); + if (entity.id === threadID) { + name = `this ${name}`; + } } if (entity.possessive) { name = makePossessive({ str: name }); @@ -219,12 +225,15 @@ return makePossessive({ str, isViewer }); } -function entityTextToRawString(entityText: EntityText): string { +function entityTextToRawString( + entityText: EntityText, + threadID: ?string, +): string { const textParts = entityText.map(entity => { if (typeof entity === 'string') { return entity; } else if (entity.type === 'thread') { - return getNameForThreadEntity(entity); + return getNameForThreadEntity(entity, threadID); } else if (entity.type === 'color') { return entity.hex; } else if (entity.type === 'user') { @@ -261,7 +270,7 @@ ); } else if (entity.type === 'thread') { const { id } = entity; - const name = getNameForThreadEntity(entity); + const name = getNameForThreadEntity(entity, threadID); if (id === threadID) { return name; } else { diff --git a/native/chat/chat-item-height-measurer.react.js b/native/chat/chat-item-height-measurer.react.js --- a/native/chat/chat-item-height-measurer.react.js +++ b/native/chat/chat-item-height-measurer.react.js @@ -29,7 +29,7 @@ if (messageInfo.type === messageTypes.TEXT) { return messageInfo.text; } else if (item.robotext) { - return robotextToRawString(item.robotext); + return robotextToRawString(item.robotext, item.messageInfo.threadID); } return null; }; @@ -43,7 +43,10 @@ if (messageInfo.type === messageTypes.TEXT) { return dummyNodeForTextMessageHeightMeasurement(messageInfo.text); } else if (item.robotext) { - return dummyNodeForRobotextMessageHeightMeasurement(item.robotext); + return dummyNodeForRobotextMessageHeightMeasurement( + item.robotext, + item.messageInfo.threadID, + ); } invariant(false, 'NodeHeightMeasurer asked for dummy for non-text message'); }; diff --git a/native/chat/inner-robotext-message.react.js b/native/chat/inner-robotext-message.react.js --- a/native/chat/inner-robotext-message.react.js +++ b/native/chat/inner-robotext-message.react.js @@ -21,11 +21,12 @@ function dummyNodeForRobotextMessageHeightMeasurement( robotext: string | EntityText, + threadID: string, ): React.Element { return ( - {robotextToRawString(robotext)} + {robotextToRawString(robotext, threadID)} );