Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3383054
D13220.id43834.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
D13220.id43834.diff
View Options
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
@@ -11,7 +11,6 @@
import { messageTypes } from '../../types/message-types-enum.js';
import { threadTypes } from '../../types/thread-types-enum.js';
import { updateTypes } from '../../types/update-types-enum.js';
-import type { ClientUpdateInfo } from '../../types/update-types.js';
import { rawMessageInfoFromMessageData } from '../message-utils.js';
import { userIsMember } from '../thread-utils.js';
@@ -45,7 +44,6 @@
rawMessageInfoFromMessageData(messageData, messageID),
];
- const updateInfos: Array<ClientUpdateInfo> = [];
if (
viewerID === editorID &&
userIsMember(threadInfo, editorID) &&
@@ -53,28 +51,50 @@
(threadInfo.parentThreadID &&
!utilities.threadInfos[threadInfo.parentThreadID]))
) {
- updateInfos.push({
- type: updateTypes.DELETE_THREAD,
- id: uuid.v4(),
- time,
- threadID,
- });
- } else {
- const updatedThreadInfo = {
- ...threadInfo,
- members: threadInfo.members.filter(member => member.id !== editorID),
+ return {
+ rawMessageInfos,
+ updateInfos: [
+ {
+ type: updateTypes.DELETE_THREAD,
+ id: uuid.v4(),
+ time,
+ threadID,
+ },
+ ],
};
- updateInfos.push({
- type: updateTypes.UPDATE_THREAD,
- id: uuid.v4(),
- time,
- threadInfo: updatedThreadInfo,
- });
}
-
+ const memberTimestamps = { ...threadInfo.timestamps.members };
+ if (!memberTimestamps[editorID]) {
+ memberTimestamps[editorID] = {
+ isMember: time,
+ subscription: threadInfo.creationTime,
+ };
+ }
+ const shouldRemoveEditor = memberTimestamps[editorID].isMember <= time;
+ memberTimestamps[editorID] = {
+ ...memberTimestamps[editorID],
+ isMember: time,
+ };
+ const updatedThreadInfo = {
+ ...threadInfo,
+ members: shouldRemoveEditor
+ ? threadInfo.members.filter(member => member.id !== editorID)
+ : threadInfo.members,
+ timestamps: {
+ ...threadInfo.timestamps,
+ members: memberTimestamps,
+ },
+ };
return {
rawMessageInfos,
- updateInfos,
+ updateInfos: [
+ {
+ type: updateTypes.UPDATE_THREAD,
+ id: uuid.v4(),
+ time,
+ threadInfo: updatedThreadInfo,
+ },
+ ],
};
},
canBeProcessed(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 29, 1:15 PM (20 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2597109
Default Alt Text
D13220.id43834.diff (2 KB)
Attached To
Mode
D13220: [lib] Check the timestamps when leaving a thread
Attached
Detach File
Event Timeline
Log In to Comment