Page MenuHomePhabricator

D6519.id21825.diff
No OneTemporary

D6519.id21825.diff

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`
};
@@ -85,6 +86,7 @@
| {
+display?: 'shortName',
+threadInfo: ThreadInfo | RawThreadInfo,
+ +subchannel?: ?boolean,
+possessive?: ?boolean,
}
| {
@@ -131,13 +133,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,
};
}
@@ -205,7 +208,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

Mime Type
text/plain
Expires
Sat, Dec 21, 11:40 AM (19 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2687537
Default Alt Text
D6519.id21825.diff (3 KB)

Event Timeline