Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3183592
D13059.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13059.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 9:43 AM (22 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2451210
Default Alt Text
D13059.diff (2 KB)
Attached To
Mode
D13059: [lib] Update the replies count
Attached
Detach File
Event Timeline
Log In to Comment