Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3294732
D6517.id21886.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D6517.id21886.diff
View Options
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
@@ -204,7 +204,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;
@@ -217,7 +220,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 });
@@ -234,12 +240,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') {
@@ -275,7 +284,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<typeof View> {
return (
<View style={unboundStyles.robotextContainer}>
<Text style={unboundStyles.dummyRobotext}>
- {robotextToRawString(robotext)}
+ {robotextToRawString(robotext, threadID)}
</Text>
</View>
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 7:57 PM (19 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2530834
Default Alt Text
D6517.id21886.diff (3 KB)
Attached To
Mode
D6517: [lib][native] Only say "this thread" in EntityText when it's the current thread
Attached
Detach File
Event Timeline
Log In to Comment