Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3100506
D13687.id45046.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
D13687.id45046.diff
View Options
diff --git a/lib/selectors/chat-selectors.js b/lib/selectors/chat-selectors.js
--- a/lib/selectors/chat-selectors.js
+++ b/lib/selectors/chat-selectors.js
@@ -21,6 +21,7 @@
robotextForMessageInfo,
sortMessageInfoList,
} from '../shared/message-utils.js';
+import { messageSpecs } from '../shared/messages/message-specs.js';
import {
threadInChatList,
threadIsPending,
@@ -424,6 +425,35 @@
continue;
}
+ const threadInfo = threadInfos[threadID];
+ const parentThreadInfo = threadInfo?.parentThreadID
+ ? threadInfos[threadInfo.parentThreadID]
+ : null;
+
+ const lastChatMessageItem =
+ chatMessageItems.length > 0
+ ? chatMessageItems[chatMessageItems.length - 1]
+ : undefined;
+ const messageSpec = messageSpecs[originalMessageInfo.type];
+ if (
+ lastChatMessageItem &&
+ lastChatMessageItem.itemType === 'message' &&
+ lastChatMessageItem.messageInfoType === 'robotext' &&
+ !isComposableMessageType(originalMessageInfo.type) &&
+ messageSpec?.mergeIntoPrecedingRobotextMessageItem
+ ) {
+ const { mergeIntoPrecedingRobotextMessageItem } = messageSpec;
+ const mergeResult = mergeIntoPrecedingRobotextMessageItem(
+ originalMessageInfo,
+ lastChatMessageItem,
+ { threadInfo, parentThreadInfo },
+ );
+ if (mergeResult.shouldMerge) {
+ chatMessageItems[chatMessageItems.length - 1] = mergeResult.item;
+ continue;
+ }
+ }
+
let hasBeenEdited = false;
if (
originalMessageInfo.type === messageTypes.TEXT &&
@@ -536,11 +566,6 @@
originalMessageInfo.type !== messageTypes.MULTIMEDIA,
"Flow doesn't understand isComposableMessageType above",
);
- const threadInfo = threadInfos[threadID];
- const parentThreadInfo = threadInfo?.parentThreadID
- ? threadInfos[threadInfo.parentThreadID]
- : null;
-
const robotext = robotextForMessageInfo(
originalMessageInfo,
threadInfo,
diff --git a/lib/shared/messages/message-spec.js b/lib/shared/messages/message-spec.js
--- a/lib/shared/messages/message-spec.js
+++ b/lib/shared/messages/message-spec.js
@@ -2,6 +2,7 @@
import type { TType } from 'tcomb';
+import type { RobotextChatMessageInfoItem } from '../../selectors/chat-selectors.js';
import type { PlatformDetails } from '../../types/device-types.js';
import type { Media } from '../../types/media-types.js';
import type {
@@ -71,6 +72,10 @@
parentThreadInfo: ?ThreadInfo,
) => Promise<mixed>;
+export type MergeRobotextMessageItemResult =
+ | { +shouldMerge: false }
+ | { +shouldMerge: true, +item: RobotextChatMessageInfoItem };
+
export type MessageSpec<Data, RawInfo, Info> = {
+messageContentForServerDB?: (data: Data | RawInfo) => string,
+messageContentForClientDB?: (data: RawInfo) => string,
@@ -121,4 +126,9 @@
+parseDerivedMessages?: (row: Object, requiredIDs: Set<string>) => void,
+useCreationSideEffectsFunc?: () => CreationSideEffectsFunc<RawInfo>,
+validator: TType<RawInfo>,
+ +mergeIntoPrecedingRobotextMessageItem?: (
+ messageInfo: Info,
+ precedingMessageInfoItem: RobotextChatMessageInfoItem,
+ params: RobotextParams,
+ ) => MergeRobotextMessageItemResult,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 31, 3:14 AM (16 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2386228
Default Alt Text
D13687.id45046.diff (3 KB)
Attached To
Mode
D13687: [lib] Introduce MessageSpec.mergeIntoPrecedingRobotextMessageItem
Attached
Detach File
Event Timeline
Log In to Comment