Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3505091
D6573.id22052.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D6573.id22052.diff
View Options
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
@@ -212,6 +212,7 @@
function getNameForThreadEntity(
entity: ThreadEntity,
threadID: ?string,
+ params?: EntityTextToRawStringParams,
): string {
const { name: userGeneratedName, display } = entity;
if (entity.display === 'uiName') {
@@ -222,12 +223,16 @@
`getNameForThreadEntity can't handle thread entity display ${display}`,
);
- let name = userGeneratedName;
+ let { name } = entity;
if (!name || entity.alwaysDisplayShortName) {
const threadType = entity.threadType ?? threadTypes.PERSONAL;
- name = entity.subchannel ? 'subchannel' : threadNoun(threadType);
+ const noun = entity.subchannel ? 'subchannel' : threadNoun(threadType);
if (entity.id === threadID) {
- name = `this ${name}`;
+ const prefixThisThreadNounWith =
+ params?.prefixThisThreadNounWith === 'your' ? 'your' : 'this';
+ name = `${prefixThisThreadNounWith} ${noun}`;
+ } else {
+ name = `a ${noun}`;
}
}
if (entity.possessive) {
@@ -252,6 +257,7 @@
type EntityTextToRawStringParams = {
+threadID?: ?string,
+ignoreViewer?: ?boolean,
+ +prefixThisThreadNounWith?: ?('this' | 'your'),
};
function entityTextToRawString(
entityText: EntityText,
@@ -261,7 +267,7 @@
if (typeof entity === 'string') {
return entity;
} else if (entity.type === 'thread') {
- return getNameForThreadEntity(entity, params?.threadID);
+ return getNameForThreadEntity(entity, params?.threadID, params);
} else if (entity.type === 'color') {
return entity.hex;
} else if (entity.type === 'user') {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 12:08 PM (19 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2687223
Default Alt Text
D6573.id22052.diff (1 KB)
Attached To
Mode
D6573: [lib] Extend EntityText to support rendering thread names for notifs
Attached
Detach File
Event Timeline
Log In to Comment