Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3503758
D6519.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
D6519.diff
View Options
diff --git a/lib/shared/messages/create-sub-thread-message-spec.js b/lib/shared/messages/create-sub-thread-message-spec.js
--- a/lib/shared/messages/create-sub-thread-message-spec.js
+++ b/lib/shared/messages/create-sub-thread-message-spec.js
@@ -17,6 +17,7 @@
import { threadPermissions, threadTypes } from '../../types/thread-types';
import type { ThreadInfo } from '../../types/thread-types';
import type { RelativeUserInfo } from '../../types/user-types';
+import { ET, type EntityText } from '../../utils/entity-text';
import {
robotextToRawString,
robotextForMessageInfo,
@@ -123,23 +124,26 @@
return { ...messageData, id };
},
- robotext(messageInfo: CreateSubthreadMessageInfo, creator: string): string {
- const childName = messageInfo.childThreadInfo.name;
- const childNoun =
- messageInfo.childThreadInfo.type === threadTypes.SIDEBAR
- ? 'thread'
- : 'subchannel';
- if (childName) {
- return (
- `${creator} created a ${childNoun}` +
- ` named "<${encodeURI(childName)}|t${messageInfo.childThreadInfo.id}>"`
- );
+ robotext(messageInfo: CreateSubthreadMessageInfo): EntityText {
+ const threadEntity = ET.thread({
+ display: 'shortName',
+ threadInfo: messageInfo.childThreadInfo,
+ subchannel: true,
+ });
+
+ let text;
+ if (messageInfo.childThreadInfo.name) {
+ const childNoun =
+ messageInfo.childThreadInfo.type === threadTypes.SIDEBAR
+ ? 'thread'
+ : 'subchannel';
+ text = ET`created a ${childNoun} named "${threadEntity}"`;
} else {
- return (
- `${creator} created a ` +
- `<${childNoun}|t${messageInfo.childThreadInfo.id}>`
- );
+ text = ET`created a ${threadEntity}`;
}
+
+ const creator = ET.user({ userInfo: messageInfo.creator });
+ return ET`${creator} ${text}`;
},
notificationTexts(
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
@@ -39,6 +39,7 @@
+display: 'shortName',
+threadType?: ?ThreadType,
+alwaysDisplayShortName?: ?boolean, // don't default to name
+ +subchannel?: ?boolean, // short name should be "subchannel"
+possessive?: ?boolean, // eg. `this thread's` instead of `this thread`
};
@@ -98,6 +99,7 @@
| {
+display?: 'shortName',
+threadInfo: ThreadInfo | RawThreadInfo,
+ +subchannel?: ?boolean,
+possessive?: ?boolean,
}
| {
@@ -144,13 +146,14 @@
possessive,
};
} else if (input.display === 'shortName' || !input.display) {
- const { threadInfo, possessive } = input;
+ const { threadInfo, subchannel, possessive } = input;
return {
type: 'thread',
id: threadInfo.id,
name: threadInfo.name,
display: 'shortName',
threadType: threadInfo.type,
+ subchannel,
possessive,
};
}
@@ -220,7 +223,7 @@
let name = userGeneratedName;
if (!name || entity.alwaysDisplayShortName) {
const threadType = entity.threadType ?? threadTypes.PERSONAL;
- name = threadNoun(threadType);
+ name = entity.subchannel ? 'subchannel' : threadNoun(threadType);
if (entity.id === threadID) {
name = `this ${name}`;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 6:31 AM (18 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2686629
Default Alt Text
D6519.diff (3 KB)
Attached To
Mode
D6519: [lib] Convert CreateSubThread robotext to use EntityText
Attached
Detach File
Event Timeline
Log In to Comment