Page MenuHomePhabricator

D6562.diff
No OneTemporary

D6562.diff

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

Mime Type
text/plain
Expires
Thu, Dec 19, 5:53 PM (20 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678238
Default Alt Text
D6562.diff (3 KB)

Event Timeline