Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3382985
D13058.id43514.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
15 KB
Referenced Files
None
Subscribers
None
D13058.id43514.diff
View Options
diff --git a/lib/shared/dm-ops/add-members-spec.js b/lib/shared/dm-ops/add-members-spec.js
--- a/lib/shared/dm-ops/add-members-spec.js
+++ b/lib/shared/dm-ops/add-members-spec.js
@@ -8,7 +8,6 @@
DMOperationSpec,
ProcessDMOperationUtilities,
} from './dm-op-spec.js';
-import { createRepliesCountUpdate } from './dm-op-utils.js';
import type { DMAddMembersOperation } from '../../types/dm-ops.js';
import { messageTypes } from '../../types/message-types-enum.js';
import { type RawMessageInfo } from '../../types/message-types.js';
@@ -77,19 +76,18 @@
...currentThreadInfo,
members: [...currentThreadInfo.members, ...newMembers],
};
- const updateWithRepliesCount = createRepliesCountUpdate(resultThreadInfo, [
- addMembersMessage,
- ]);
- const update = updateWithRepliesCount ?? {
- type: updateTypes.UPDATE_THREAD,
- id: uuid.v4(),
- time,
- threadInfo: resultThreadInfo,
- };
+ const updateInfos = [
+ {
+ type: updateTypes.UPDATE_THREAD,
+ id: uuid.v4(),
+ time,
+ threadInfo: resultThreadInfo,
+ },
+ ];
return {
rawMessageInfos: [addMembersMessage],
- updateInfos: [update],
+ updateInfos,
threadInfo: resultThreadInfo,
};
}
diff --git a/lib/shared/dm-ops/add-viewer-to-thread-members-spec.js b/lib/shared/dm-ops/add-viewer-to-thread-members-spec.js
--- a/lib/shared/dm-ops/add-viewer-to-thread-members-spec.js
+++ b/lib/shared/dm-ops/add-viewer-to-thread-members-spec.js
@@ -5,12 +5,10 @@
import type { AddMembersResult } from './add-members-spec.js';
import { createThickRawThreadInfo } from './create-thread-spec.js';
import type { DMOperationSpec } from './dm-op-spec.js';
-import { createRepliesCountUpdate } from './dm-op-utils.js';
import type { DMAddViewerToThreadMembersOperation } from '../../types/dm-ops.js';
import { messageTypes } from '../../types/message-types-enum.js';
import { messageTruncationStatus } from '../../types/message-types.js';
import { updateTypes } from '../../types/update-types-enum.js';
-import type { ClientUpdateInfo } from '../../types/update-types.js';
function createAddViewerToThreadMembersResults(
dmOperation: DMAddViewerToThreadMembersOperation,
@@ -27,8 +25,6 @@
addedUserIDs: [...addedUserIDs],
};
- const updateInfos: Array<ClientUpdateInfo> = [];
-
const resultThreadInfo = createThickRawThreadInfo(
{
...existingThreadDetails,
@@ -36,25 +32,17 @@
},
viewerID,
);
- updateInfos.push({
- type: updateTypes.JOIN_THREAD,
- id: uuid.v4(),
- time,
- threadInfo: resultThreadInfo,
- rawMessageInfos: [addMembersMessage],
- truncationStatus: messageTruncationStatus.EXHAUSTIVE,
- rawEntryInfos: [],
- });
- const repliesCountUpdate = createRepliesCountUpdate(resultThreadInfo, [
- addMembersMessage,
- ]);
- if (
- repliesCountUpdate &&
- repliesCountUpdate.type === updateTypes.UPDATE_THREAD
- ) {
- updateInfos.push(repliesCountUpdate);
- resultThreadInfo.repliesCount = repliesCountUpdate.threadInfo.repliesCount;
- }
+ const updateInfos = [
+ {
+ type: updateTypes.JOIN_THREAD,
+ id: uuid.v4(),
+ time,
+ threadInfo: resultThreadInfo,
+ rawMessageInfos: [addMembersMessage],
+ truncationStatus: messageTruncationStatus.EXHAUSTIVE,
+ rawEntryInfos: [],
+ },
+ ];
return {
rawMessageInfos: [],
updateInfos,
diff --git a/lib/shared/dm-ops/change-thread-settings-spec.js b/lib/shared/dm-ops/change-thread-settings-spec.js
--- a/lib/shared/dm-ops/change-thread-settings-spec.js
+++ b/lib/shared/dm-ops/change-thread-settings-spec.js
@@ -11,7 +11,6 @@
DMOperationSpec,
ProcessDMOperationUtilities,
} from './dm-op-spec.js';
-import { createRepliesCountUpdate } from './dm-op-utils.js';
import type {
DMChangeThreadSettingsAndAddViewerOperation,
DMChangeThreadSettingsOperation,
@@ -126,13 +125,7 @@
});
}
- const repliesCountUpdate = createRepliesCountUpdate(
- threadInfoToUpdate,
- rawMessageInfos,
- );
- if (repliesCountUpdate) {
- updateInfos.push(repliesCountUpdate);
- } else if (values(changedFields).length > 0) {
+ if (values(changedFields).length > 0) {
updateInfos.push({
type: updateTypes.UPDATE_THREAD,
id: uuid.v4(),
diff --git a/lib/shared/dm-ops/create-sidebar-spec.js b/lib/shared/dm-ops/create-sidebar-spec.js
--- a/lib/shared/dm-ops/create-sidebar-spec.js
+++ b/lib/shared/dm-ops/create-sidebar-spec.js
@@ -48,7 +48,6 @@
creatorID,
sourceMessageID,
containingThreadID: parentThreadID,
- repliesCount: 1,
},
viewerID,
);
diff --git a/lib/shared/dm-ops/dm-op-utils.js b/lib/shared/dm-ops/dm-op-utils.js
--- a/lib/shared/dm-ops/dm-op-utils.js
+++ b/lib/shared/dm-ops/dm-op-utils.js
@@ -3,24 +3,16 @@
import uuid from 'uuid';
import type { DMOperation } from '../../types/dm-ops.js';
-import { messageTypes } from '../../types/message-types-enum.js';
-import type { RawMessageInfo } from '../../types/message-types.js';
-import type { RawThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js';
import {
outboundP2PMessageStatuses,
type OutboundP2PMessage,
} from '../../types/sqlite-types.js';
-import { threadTypes } from '../../types/thread-types-enum.js';
-import type { LegacyRawThreadInfo } from '../../types/thread-types.js';
import {
type DMOperationP2PMessage,
userActionsP2PMessageTypes,
} from '../../types/tunnelbroker/user-actions-peer-to-peer-message-types.js';
-import { updateTypes } from '../../types/update-types-enum.js';
-import type { ClientUpdateInfo } from '../../types/update-types.js';
import type { CurrentUserInfo } from '../../types/user-types.js';
import { getContentSigningKey } from '../../utils/crypto-utils.js';
-import { messageSpecs } from '../messages/message-specs.js';
function generateMessagesToPeers(
message: DMOperation,
@@ -95,35 +87,4 @@
);
}
-function createRepliesCountUpdate(
- threadInfo: RawThreadInfo | LegacyRawThreadInfo,
- newMessages: $ReadOnlyArray<RawMessageInfo>,
-): ?ClientUpdateInfo {
- if (threadInfo.type !== threadTypes.THICK_SIDEBAR) {
- return null;
- }
- const includedMessageTypes = new Set(
- Object.keys(messageTypes)
- .map(key => messageTypes[key])
- .filter(type => messageSpecs[type].includedInRepliesCount),
- );
- const filteredMessages = newMessages.filter(message =>
- includedMessageTypes.has(message.type),
- );
- const countIncrease = filteredMessages.length;
- if (countIncrease === 0) {
- return null;
- }
- const time = Math.max(...filteredMessages.map(message => message.time));
- return {
- type: updateTypes.UPDATE_THREAD,
- id: uuid.v4(),
- time,
- threadInfo: {
- ...threadInfo,
- repliesCount: threadInfo.repliesCount + countIncrease,
- },
- };
-}
-
-export { createMessagesToPeersFromDMOp, createRepliesCountUpdate };
+export { createMessagesToPeersFromDMOp };
diff --git a/lib/shared/dm-ops/join-thread-spec.js b/lib/shared/dm-ops/join-thread-spec.js
--- a/lib/shared/dm-ops/join-thread-spec.js
+++ b/lib/shared/dm-ops/join-thread-spec.js
@@ -11,7 +11,6 @@
DMOperationSpec,
ProcessDMOperationUtilities,
} from './dm-op-spec.js';
-import { createRepliesCountUpdate } from './dm-op-utils.js';
import type { DMJoinThreadOperation } from '../../types/dm-ops.js';
import { messageTypes } from '../../types/message-types-enum.js';
import {
@@ -71,12 +70,6 @@
truncationStatus: messageTruncationStatus.EXHAUSTIVE,
rawEntryInfos: [],
});
- const repliesCountUpdate = createRepliesCountUpdate(newThreadInfo, [
- joinThreadMessage,
- ]);
- if (repliesCountUpdate) {
- updateInfos.push(repliesCountUpdate);
- }
} else {
invariant(currentThreadInfo.thick, 'Thread should be thick');
@@ -102,18 +95,12 @@
...currentThreadInfo,
members: [...currentThreadInfo.members, member],
};
- const updateWithRepliesCount = createRepliesCountUpdate(
- updatedThreadInfo,
- [joinThreadMessage],
- );
- updateInfos.push(
- updateWithRepliesCount ?? {
- type: updateTypes.UPDATE_THREAD,
- id: uuid.v4(),
- time,
- threadInfo: updatedThreadInfo,
- },
- );
+ updateInfos.push({
+ type: updateTypes.UPDATE_THREAD,
+ id: uuid.v4(),
+ time,
+ threadInfo: updatedThreadInfo,
+ });
}
return {
rawMessageInfos,
diff --git a/lib/shared/dm-ops/leave-thread-spec.js b/lib/shared/dm-ops/leave-thread-spec.js
--- a/lib/shared/dm-ops/leave-thread-spec.js
+++ b/lib/shared/dm-ops/leave-thread-spec.js
@@ -7,7 +7,6 @@
DMOperationSpec,
ProcessDMOperationUtilities,
} from './dm-op-spec.js';
-import { createRepliesCountUpdate } from './dm-op-utils.js';
import type { DMLeaveThreadOperation } from '../../types/dm-ops.js';
import { messageTypes } from '../../types/message-types-enum.js';
import { threadTypes } from '../../types/thread-types-enum.js';
@@ -53,18 +52,12 @@
...threadInfo,
members: threadInfo.members.filter(member => member.id !== editorID),
};
- const updateWithRepliesCount = createRepliesCountUpdate(
- updatedThreadInfo,
- [leaveThreadMessage],
- );
- updateInfos.push(
- updateWithRepliesCount ?? {
- type: updateTypes.UPDATE_THREAD,
- id: uuid.v4(),
- time,
- threadInfo: updatedThreadInfo,
- },
- );
+ updateInfos.push({
+ type: updateTypes.UPDATE_THREAD,
+ id: uuid.v4(),
+ time,
+ threadInfo: updatedThreadInfo,
+ });
}
return {
diff --git a/lib/shared/dm-ops/remove-members-spec.js b/lib/shared/dm-ops/remove-members-spec.js
--- a/lib/shared/dm-ops/remove-members-spec.js
+++ b/lib/shared/dm-ops/remove-members-spec.js
@@ -7,7 +7,6 @@
DMOperationSpec,
ProcessDMOperationUtilities,
} from './dm-op-spec.js';
-import { createRepliesCountUpdate } from './dm-op-utils.js';
import type { DMRemoveMembersOperation } from '../../types/dm-ops.js';
import { messageTypes } from '../../types/message-types-enum.js';
import { threadTypes } from '../../types/thread-types-enum.js';
@@ -58,18 +57,12 @@
member => !removedUserIDsSet.has(member.id),
),
};
- const updateWithRepliesCount = createRepliesCountUpdate(
- updatedThreadInfo,
- [removeMembersMessage],
- );
- updateInfos.push(
- updateWithRepliesCount ?? {
- type: updateTypes.UPDATE_THREAD,
- id: uuid.v4(),
- time,
- threadInfo: updatedThreadInfo,
- },
- );
+ updateInfos.push({
+ type: updateTypes.UPDATE_THREAD,
+ id: uuid.v4(),
+ time,
+ threadInfo: updatedThreadInfo,
+ });
}
return {
rawMessageInfos: [removeMembersMessage],
diff --git a/lib/shared/dm-ops/send-edit-message-spec.js b/lib/shared/dm-ops/send-edit-message-spec.js
--- a/lib/shared/dm-ops/send-edit-message-spec.js
+++ b/lib/shared/dm-ops/send-edit-message-spec.js
@@ -4,18 +4,12 @@
DMOperationSpec,
ProcessDMOperationUtilities,
} from './dm-op-spec.js';
-import { createRepliesCountUpdate } from './dm-op-utils.js';
import type { DMSendEditMessageOperation } from '../../types/dm-ops.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type { ClientUpdateInfo } from '../../types/update-types.js';
const sendEditMessageSpec: DMOperationSpec<DMSendEditMessageOperation> =
Object.freeze({
- processDMOperation: async (
- dmOperation: DMSendEditMessageOperation,
- viewerID: string,
- utilities: ProcessDMOperationUtilities,
- ) => {
+ processDMOperation: async (dmOperation: DMSendEditMessageOperation) => {
const { threadID, creatorID, time, messageID, targetMessageID, text } =
dmOperation;
const editMessage = {
@@ -28,17 +22,9 @@
text,
};
- const updateInfos: Array<ClientUpdateInfo> = [];
- const threadInfo = utilities.threadInfos[threadID];
- const repliesCountUpdate = createRepliesCountUpdate(threadInfo, [
- editMessage,
- ]);
- if (repliesCountUpdate) {
- updateInfos.push(repliesCountUpdate);
- }
return {
rawMessageInfos: [editMessage],
- updateInfos,
+ updateInfos: [],
};
},
canBeProcessed(
diff --git a/lib/shared/dm-ops/send-reaction-message-spec.js b/lib/shared/dm-ops/send-reaction-message-spec.js
--- a/lib/shared/dm-ops/send-reaction-message-spec.js
+++ b/lib/shared/dm-ops/send-reaction-message-spec.js
@@ -4,18 +4,12 @@
DMOperationSpec,
ProcessDMOperationUtilities,
} from './dm-op-spec.js';
-import { createRepliesCountUpdate } from './dm-op-utils.js';
import type { DMSendReactionMessageOperation } from '../../types/dm-ops.js';
import { messageTypes } from '../../types/message-types-enum.js';
-import type { ClientUpdateInfo } from '../../types/update-types.js';
const sendReactionMessageSpec: DMOperationSpec<DMSendReactionMessageOperation> =
Object.freeze({
- processDMOperation: async (
- dmOperation: DMSendReactionMessageOperation,
- viewerID: string,
- utilities: ProcessDMOperationUtilities,
- ) => {
+ processDMOperation: async (dmOperation: DMSendReactionMessageOperation) => {
const {
threadID,
creatorID,
@@ -36,17 +30,9 @@
action,
};
- const updateInfos: Array<ClientUpdateInfo> = [];
- const threadInfo = utilities.threadInfos[threadID];
- const repliesCountUpdate = createRepliesCountUpdate(threadInfo, [
- reactionMessage,
- ]);
- if (repliesCountUpdate) {
- updateInfos.push(repliesCountUpdate);
- }
return {
rawMessageInfos: [reactionMessage],
- updateInfos,
+ updateInfos: [],
};
},
canBeProcessed(
diff --git a/lib/shared/dm-ops/send-text-message-spec.js b/lib/shared/dm-ops/send-text-message-spec.js
--- a/lib/shared/dm-ops/send-text-message-spec.js
+++ b/lib/shared/dm-ops/send-text-message-spec.js
@@ -4,18 +4,13 @@
DMOperationSpec,
ProcessDMOperationUtilities,
} from './dm-op-spec.js';
-import { createRepliesCountUpdate } from './dm-op-utils.js';
import type { DMSendTextMessageOperation } from '../../types/dm-ops.js';
import { messageTypes } from '../../types/message-types-enum.js';
import type { ClientUpdateInfo } from '../../types/update-types.js';
const sendTextMessageSpec: DMOperationSpec<DMSendTextMessageOperation> =
Object.freeze({
- processDMOperation: async (
- dmOperation: DMSendTextMessageOperation,
- viewerID: string,
- utilities: ProcessDMOperationUtilities,
- ) => {
+ processDMOperation: async (dmOperation: DMSendTextMessageOperation) => {
const { threadID, creatorID, time, messageID, text } = dmOperation;
const textMessage = {
type: messageTypes.TEXT,
@@ -26,13 +21,6 @@
text,
};
const updateInfos: Array<ClientUpdateInfo> = [];
- const threadInfo = utilities.threadInfos[threadID];
- const repliesCountUpdate = createRepliesCountUpdate(threadInfo, [
- textMessage,
- ]);
- if (repliesCountUpdate) {
- updateInfos.push(repliesCountUpdate);
- }
return {
rawMessageInfos: [textMessage],
updateInfos,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 29, 12:58 PM (21 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2597066
Default Alt Text
D13058.id43514.diff (15 KB)
Attached To
Mode
D13058: [lib] Delete old replies count logic
Attached
Detach File
Event Timeline
Log In to Comment