Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3392531
D7078.id23799.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D7078.id23799.diff
View Options
diff --git a/lib/shared/messages/change-settings-message-spec.js b/lib/shared/messages/change-settings-message-spec.js
--- a/lib/shared/messages/change-settings-message-spec.js
+++ b/lib/shared/messages/change-settings-message-spec.js
@@ -2,7 +2,11 @@
import invariant from 'invariant';
-import { pushTypes, type MessageSpec } from './message-spec.js';
+import {
+ pushTypes,
+ type MessageSpec,
+ type RobotextParams,
+} from './message-spec.js';
import { joinResult } from './utils.js';
import { messageTypes } from '../../types/message-types.js';
import type {
@@ -99,17 +103,23 @@
return { ...messageData, id };
},
- robotext(messageInfo: ChangeSettingsMessageInfo): EntityText {
+ robotext(
+ messageInfo: ChangeSettingsMessageInfo,
+ params: RobotextParams,
+ ): EntityText {
const creator = ET.user({ userInfo: messageInfo.creator });
+ const thread = ET.thread({
+ display: 'alwaysDisplayShortName',
+ threadID: messageInfo.threadID,
+ threadType: params.threadInfo?.type,
+ parentThreadID: params.threadInfo?.parentThreadID,
+ possessive: true,
+ });
if (
(messageInfo.field === 'name' || messageInfo.field === 'description') &&
messageInfo.value.toString() === ''
) {
- return ET`${creator} cleared ${ET.thread({
- display: 'alwaysDisplayShortName',
- threadID: messageInfo.threadID,
- possessive: true,
- })} ${messageInfo.field}`;
+ return ET`${creator} cleared ${thread} ${messageInfo.field}`;
}
let value;
if (
@@ -127,11 +137,7 @@
} else {
value = messageInfo.value.toString();
}
- return ET`${creator} updated ${ET.thread({
- display: 'alwaysDisplayShortName',
- threadID: messageInfo.threadID,
- possessive: true,
- })} ${messageInfo.field} to "${value}"`;
+ return ET`${creator} updated ${thread} ${messageInfo.field} to "${value}"`;
},
async notificationTexts(
diff --git a/lib/shared/messages/create-sidebar-message-spec.js b/lib/shared/messages/create-sidebar-message-spec.js
--- a/lib/shared/messages/create-sidebar-message-spec.js
+++ b/lib/shared/messages/create-sidebar-message-spec.js
@@ -7,6 +7,7 @@
type CreateMessageInfoParams,
type MessageSpec,
type NotificationTextsParams,
+ type RobotextParams,
} from './message-spec.js';
import { joinResult } from './utils.js';
import type { PlatformDetails } from '../../types/device-types.js';
@@ -133,10 +134,15 @@
return { ...messageData, id };
},
- robotext(messageInfo: CreateSidebarMessageInfo): EntityText {
+ robotext(
+ messageInfo: CreateSidebarMessageInfo,
+ params: RobotextParams,
+ ): EntityText {
let text = ET`started ${ET.thread({
display: 'alwaysDisplayShortName',
threadID: messageInfo.threadID,
+ threadType: params.threadInfo?.type,
+ parentThreadID: params.threadInfo?.parentThreadID,
})}`;
const users = messageInfo.initialThreadState.otherMembers.filter(
member => member.id !== messageInfo.sourceMessageAuthor.id,
diff --git a/lib/shared/messages/create-thread-message-spec.js b/lib/shared/messages/create-thread-message-spec.js
--- a/lib/shared/messages/create-thread-message-spec.js
+++ b/lib/shared/messages/create-thread-message-spec.js
@@ -6,6 +6,7 @@
pushTypes,
type CreateMessageInfoParams,
type MessageSpec,
+ type RobotextParams,
} from './message-spec.js';
import { assertSingleMessageInfo } from './utils.js';
import { messageTypes } from '../../types/message-types.js';
@@ -113,10 +114,15 @@
return { ...messageData, id };
},
- robotext(messageInfo: CreateThreadMessageInfo): EntityText {
+ robotext(
+ messageInfo: CreateThreadMessageInfo,
+ params: RobotextParams,
+ ): EntityText {
let text = ET`created ${ET.thread({
display: 'alwaysDisplayShortName',
threadID: messageInfo.threadID,
+ threadType: params.threadInfo?.type,
+ parentThreadID: params.threadInfo?.parentThreadID,
})}`;
const parentThread = messageInfo.initialThreadState.parentThreadInfo;
if (parentThread) {
diff --git a/lib/shared/messages/join-thread-message-spec.js b/lib/shared/messages/join-thread-message-spec.js
--- a/lib/shared/messages/join-thread-message-spec.js
+++ b/lib/shared/messages/join-thread-message-spec.js
@@ -2,7 +2,7 @@
import invariant from 'invariant';
-import type { MessageSpec } from './message-spec.js';
+import type { MessageSpec, RobotextParams } from './message-spec.js';
import { joinResult } from './utils.js';
import { messageTypes } from '../../types/message-types.js';
import type {
@@ -73,11 +73,16 @@
return { ...messageData, id };
},
- robotext(messageInfo: JoinThreadMessageInfo): EntityText {
+ robotext(
+ messageInfo: JoinThreadMessageInfo,
+ params: RobotextParams,
+ ): EntityText {
const creator = ET.user({ userInfo: messageInfo.creator });
return ET`${creator} joined ${ET.thread({
display: 'alwaysDisplayShortName',
threadID: messageInfo.threadID,
+ threadType: params.threadInfo?.type,
+ parentThreadID: params.threadInfo?.parentThreadID,
})}`;
},
diff --git a/lib/shared/messages/leave-thread-message-spec.js b/lib/shared/messages/leave-thread-message-spec.js
--- a/lib/shared/messages/leave-thread-message-spec.js
+++ b/lib/shared/messages/leave-thread-message-spec.js
@@ -2,7 +2,7 @@
import invariant from 'invariant';
-import type { MessageSpec } from './message-spec.js';
+import type { MessageSpec, RobotextParams } from './message-spec.js';
import { joinResult } from './utils.js';
import { messageTypes } from '../../types/message-types.js';
import type {
@@ -73,11 +73,16 @@
return { ...messageData, id };
},
- robotext(messageInfo: LeaveThreadMessageInfo): EntityText {
+ robotext(
+ messageInfo: LeaveThreadMessageInfo,
+ params: RobotextParams,
+ ): EntityText {
const creator = ET.user({ userInfo: messageInfo.creator });
return ET`${creator} left ${ET.thread({
display: 'alwaysDisplayShortName',
threadID: messageInfo.threadID,
+ threadType: params.threadInfo?.type,
+ parentThreadID: params.threadInfo?.parentThreadID,
})}`;
},
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
@@ -42,6 +42,7 @@
// displays threadInfo.name if set, or eg. 'this thread' or 'this chat'
+display: 'shortName',
+threadType?: ?ThreadType,
+ +parentThreadID?: ?string,
+alwaysDisplayShortName?: ?boolean, // don't default to name
+subchannel?: ?boolean, // short name should be "subchannel"
+possessive?: ?boolean, // eg. `this thread's` instead of `this thread`
@@ -114,6 +115,8 @@
| {
+display: 'alwaysDisplayShortName',
+threadID: string,
+ +parentThreadID?: ?string,
+ +threadType?: ?ThreadType,
+possessive?: ?boolean,
};
entityTextFunction.thread = (input: EntityTextThreadInput) => {
@@ -131,13 +134,14 @@
};
}
if (input.display === 'alwaysDisplayShortName' && input.threadID) {
- const { threadID, possessive } = input;
+ const { threadID, threadType, parentThreadID, possessive } = input;
return {
type: 'thread',
id: threadID,
name: undefined,
display: 'shortName',
- threadType: undefined,
+ threadType,
+ parentThreadID,
alwaysDisplayShortName: true,
possessive,
};
@@ -149,6 +153,7 @@
name: threadInfo.name,
display: 'shortName',
threadType: threadInfo.type,
+ parentThreadID: threadInfo.parentThreadID,
alwaysDisplayShortName: true,
possessive,
};
@@ -160,6 +165,7 @@
name: threadInfo.name,
display: 'shortName',
threadType: threadInfo.type,
+ parentThreadID: threadInfo.parentThreadID,
subchannel,
possessive,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 1, 9:02 AM (19 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2604207
Default Alt Text
D7078.id23799.diff (7 KB)
Attached To
Mode
D7078: [lib] Pass threadType and parentThreadID to alwaysDisplayShortName ThreadEntity
Attached
Detach File
Event Timeline
Log In to Comment