Page MenuHomePhabricator

D13059.diff
No OneTemporary

D13059.diff

diff --git a/lib/shared/dm-ops/process-dm-ops.js b/lib/shared/dm-ops/process-dm-ops.js
--- a/lib/shared/dm-ops/process-dm-ops.js
+++ b/lib/shared/dm-ops/process-dm-ops.js
@@ -17,8 +17,13 @@
processDMOpsActionType,
queueDMOpsActionType,
} from '../../types/dm-ops.js';
+import type { RawThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js';
+import { threadTypes } from '../../types/thread-types-enum.js';
+import type { LegacyRawThreadInfo } from '../../types/thread-types.js';
import { updateTypes } from '../../types/update-types-enum.js';
import { useSelector } from '../../utils/redux-utils.js';
+import { messageSpecs } from '../messages/message-specs.js';
+import { updateSpecs } from '../updates/update-specs.js';
function useProcessDMOperation(): (
dmOp: DMOperation,
@@ -74,7 +79,47 @@
const messagesByThreadID = _groupBy(message => message.threadID)(
allNewMessageInfos,
);
+
+ const updatedThreadInfosByThreadID: {
+ [string]: RawThreadInfo | LegacyRawThreadInfo,
+ } = {};
+ for (const threadID in messagesByThreadID) {
+ updatedThreadInfosByThreadID[threadID] = threadInfos[threadID];
+ }
+ for (const update of updateInfos) {
+ const updatedThreadInfo = updateSpecs[
+ update.type
+ ].getUpdatedThreadInfo?.(update, updatedThreadInfosByThreadID);
+ if (
+ updatedThreadInfo &&
+ updatedThreadInfo?.type === threadTypes.THICK_SIDEBAR
+ ) {
+ updatedThreadInfosByThreadID[updatedThreadInfo.id] =
+ updatedThreadInfo;
+ }
+ }
+
for (const threadID in messagesByThreadID) {
+ const repliesCountIncreasingMessages = messagesByThreadID[
+ threadID
+ ].filter(message => messageSpecs[message.type].includedInRepliesCount);
+ if (repliesCountIncreasingMessages.length > 0) {
+ const threadInfo = updatedThreadInfosByThreadID[threadID];
+ const repliesCountIncreaseTime = Math.max(
+ repliesCountIncreasingMessages.map(message => message.time),
+ );
+ updateInfos.push({
+ type: updateTypes.UPDATE_THREAD,
+ id: uuid.v4(),
+ time: repliesCountIncreaseTime,
+ threadInfo: {
+ ...threadInfo,
+ repliesCount:
+ threadInfo.repliesCount + repliesCountIncreasingMessages.length,
+ },
+ });
+ }
+
const messagesFromOtherPeers = messagesByThreadID[threadID].filter(
message => message.creatorID !== viewerID,
);
@@ -106,7 +151,7 @@
metadata,
);
},
- [viewerID, utilities, dispatchWithMessageSource],
+ [viewerID, utilities, dispatchWithMessageSource, threadInfos],
);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Sep 20, 9:23 AM (18 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2147996
Default Alt Text
D13059.diff (2 KB)

Event Timeline