Page MenuHomePhabricator

D5886.id19441.diff
No OneTemporary

D5886.id19441.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
@@ -4,7 +4,6 @@
import _maxBy from 'lodash/fp/maxBy';
import _orderBy from 'lodash/fp/orderBy';
-import { multimediaMessagePreview } from '../media/media-utils';
import { userIDsToRelativeUserInfos } from '../selectors/user-selectors';
import type { PlatformDetails } from '../types/device-types';
import type { Media } from '../types/media-types';
@@ -13,7 +12,6 @@
type RawMessageInfo,
type ReactionMessageInfo,
type RobotextMessageInfo,
- type PreviewableMessageInfo,
type RawMultimediaMessageInfo,
type MessageData,
type MessageType,
@@ -290,29 +288,6 @@
});
}
-function reactionMessagePreview(): string {
- return 'liked a message';
-}
-
-function messagePreviewText(
- messageInfo: PreviewableMessageInfo,
- threadInfo: ThreadInfo,
-): string {
- if (
- messageInfo.type === messageTypes.IMAGES ||
- messageInfo.type === messageTypes.MULTIMEDIA ||
- messageInfo.type === messageTypes.REACTION
- ) {
- const creator = stringForUser(messageInfo.creator);
- const preview =
- messageInfo.type === messageTypes.REACTION
- ? reactionMessagePreview()
- : multimediaMessagePreview(messageInfo);
- return `${creator} ${preview}`;
- }
- return robotextToRawString(robotextForMessageInfo(messageInfo, threadInfo));
-}
-
type MediaMessageDataCreationInput = $ReadOnly<{
threadID: string,
creatorID: string,
@@ -569,7 +544,6 @@
usersInMessageInfos,
combineTruncationStatuses,
shimUnsupportedRawMessageInfos,
- messagePreviewText,
createMediaMessageData,
createMediaMessageInfo,
stripLocalIDs,
diff --git a/lib/shared/messages/multimedia-message-spec.js b/lib/shared/messages/multimedia-message-spec.js
--- a/lib/shared/messages/multimedia-message-spec.js
+++ b/lib/shared/messages/multimedia-message-spec.js
@@ -42,7 +42,8 @@
} from '../../utils/message-ops-utils';
import {
createMediaMessageInfo,
- messagePreviewText,
+ robotextToRawString,
+ robotextForMessageInfo,
removeCreatorAsViewer,
} from '../message-utils';
import { threadIsGroupChat } from '../thread-utils';
@@ -370,6 +371,21 @@
}
}
+function messagePreviewText(
+ messageInfo: MultimediaMessageInfo,
+ threadInfo: ThreadInfo,
+): string {
+ if (
+ messageInfo.type === messageTypes.IMAGES ||
+ messageInfo.type === messageTypes.MULTIMEDIA
+ ) {
+ const creator = stringForUser(messageInfo.creator);
+ const preview = multimediaMessagePreview(messageInfo);
+ return `${creator} ${preview}`;
+ }
+ return robotextToRawString(robotextForMessageInfo(messageInfo, threadInfo));
+}
+
// Four photos were uploaded before dimensions were calculated server-side,
// and delivered to clients without dimensions in the MultimediaMessageInfo.
const preDimensionUploads = {
diff --git a/lib/shared/messages/reaction-message-spec.js b/lib/shared/messages/reaction-message-spec.js
--- a/lib/shared/messages/reaction-message-spec.js
+++ b/lib/shared/messages/reaction-message-spec.js
@@ -16,7 +16,11 @@
import type { NotifTexts } from '../../types/notif-types';
import type { ThreadInfo } from '../../types/thread-types';
import type { RelativeUserInfo } from '../../types/user-types';
-import { messagePreviewText, removeCreatorAsViewer } from '../message-utils';
+import {
+ removeCreatorAsViewer,
+ robotextToRawString,
+ robotextForMessageInfo,
+} from '../message-utils';
import { threadIsGroupChat } from '../thread-utils';
import { stringForUser } from '../user-utils';
import { hasMinCodeVersion } from '../version-utils';
@@ -204,3 +208,18 @@
generatesNotifs: true,
});
+
+function messagePreviewText(
+ messageInfo: ReactionMessageInfo,
+ threadInfo: ThreadInfo,
+): string {
+ if (messageInfo.type === messageTypes.REACTION) {
+ const creator = stringForUser(messageInfo.creator);
+ const preview =
+ messageInfo.action === 'add_reaction'
+ ? 'liked a message'
+ : 'unliked a message';
+ return `${creator} ${preview}`;
+ }
+ return robotextToRawString(robotextForMessageInfo(messageInfo, threadInfo));
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 9:33 PM (19 h, 27 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2606157
Default Alt Text
D5886.id19441.diff (4 KB)

Event Timeline