Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3527761
D6562.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
D6562.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
@@ -349,10 +349,6 @@
return thread?.messageIDs.find(id => !id.startsWith(localIDPrefix));
}
-export type GetMessageTitleViewerContext =
- | 'global_viewer'
- | 'individual_viewer';
-
function getMessageTitle(
messageInfo:
| ComposableMessageInfo
@@ -360,26 +356,20 @@
| ReactionMessageInfo,
threadInfo: ThreadInfo,
markdownRules: ParserRules,
- viewerContext?: GetMessageTitleViewerContext = 'individual_viewer',
-): string {
- let entityText;
+): EntityText {
const { messageTitle } = messageSpecs[messageInfo.type];
- if (!messageTitle) {
- invariant(
- messageInfo.type !== messageTypes.TEXT &&
- messageInfo.type !== messageTypes.IMAGES &&
- messageInfo.type !== messageTypes.MULTIMEDIA &&
- messageInfo.type !== messageTypes.REACTION,
- 'messageTitle can only be auto-generated for RobotextMessageInfo',
- );
- entityText = robotextForMessageInfo(messageInfo, threadInfo);
- } else {
- entityText = messageTitle({ messageInfo, threadInfo, markdownRules });
+ if (messageTitle) {
+ return messageTitle({ messageInfo, threadInfo, markdownRules });
}
- return entityTextToRawString(entityText, {
- threadID: threadInfo.id,
- ignoreViewer: viewerContext === 'global_viewer',
- });
+
+ invariant(
+ messageInfo.type !== messageTypes.TEXT &&
+ messageInfo.type !== messageTypes.IMAGES &&
+ messageInfo.type !== messageTypes.MULTIMEDIA &&
+ messageInfo.type !== messageTypes.REACTION,
+ 'messageTitle can only be auto-generated for RobotextMessageInfo',
+ );
+ return robotextForMessageInfo(messageInfo, threadInfo);
}
function mergeThreadMessageInfos(
@@ -494,11 +484,14 @@
if (!messageInfo) {
return messageInfo;
}
- const messageTitle = getMessageTitle(
+ const messageTitleEntityText = getMessageTitle(
messageInfo,
threadInfo,
markdownRules,
);
+ const messageTitle = entityTextToRawString(messageTitleEntityText, {
+ threadID: threadInfo.id,
+ });
let style;
if (unread) {
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -71,6 +71,7 @@
} from '../types/user-types';
import { useDispatchActionPromise, useServerCall } from '../utils/action-utils';
import type { DispatchActionPromise } from '../utils/action-utils';
+import { entityTextToRawString } from '../utils/entity-text';
import { values } from '../utils/objects';
import { useSelector } from '../utils/redux-utils';
import { firstLine } from '../utils/string-utils';
@@ -428,12 +429,14 @@
): ThreadInfo {
const { color, type: parentThreadType } = parentThreadInfo;
- const messageTitle = getMessageTitle(
+ const messageTitleEntityText = getMessageTitle(
sourceMessageInfo,
parentThreadInfo,
markdownRules,
- 'global_viewer',
);
+ const messageTitle = entityTextToRawString(messageTitleEntityText, {
+ ignoreViewer: true,
+ });
const threadName = trimText(messageTitle, 30);
const initialMembers = new Map();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 6:35 AM (11 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2701847
Default Alt Text
D6562.diff (3 KB)
Attached To
Mode
D6562: [lib] Return EntityText from getMessageTitle
Attached
Detach File
Event Timeline
Log In to Comment