Page MenuHomePhabricator

D13291.diff
No OneTemporary

D13291.diff

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
@@ -9,8 +9,12 @@
} from './dm-op-spec.js';
import type { DMLeaveThreadOperation } from '../../types/dm-ops.js';
import { messageTypes } from '../../types/message-types-enum.js';
+import type { ThickRawThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js';
import { threadTypes } from '../../types/thread-types-enum.js';
+import type { RawThreadInfos } from '../../types/thread-types.js';
import { updateTypes } from '../../types/update-types-enum.js';
+import type { ClientUpdateInfo } from '../../types/update-types.js';
+import { values } from '../../utils/objects.js';
import { rawMessageInfoFromMessageData } from '../message-utils.js';
import { userIsMember } from '../thread-utils.js';
@@ -24,6 +28,29 @@
};
}
+function createLeaveThreadSubthreadsUpdates(
+ dmOperation: DMLeaveThreadOperation,
+ threadInfo: ThickRawThreadInfo,
+ viewerID: string,
+ threadInfos: RawThreadInfos,
+): $ReadOnlyArray<ClientUpdateInfo> {
+ const updates = [];
+ for (const thread of values(threadInfos)) {
+ if (thread.parentThreadID !== threadInfo.id) {
+ continue;
+ }
+
+ updates.push({
+ type: updateTypes.DELETE_THREAD,
+ id: uuid.v4(),
+ time: dmOperation.time,
+ threadID: thread.id,
+ });
+ }
+
+ return updates;
+}
+
const leaveThreadSpec: DMOperationSpec<DMLeaveThreadOperation> = Object.freeze({
notificationsCreationData: async (dmOperation: DMLeaveThreadOperation) => {
const messageData = createMessageDataFromDMOperation(dmOperation);
@@ -60,6 +87,12 @@
time,
threadID,
},
+ ...createLeaveThreadSubthreadsUpdates(
+ dmOperation,
+ threadInfo,
+ viewerID,
+ utilities.threadInfos,
+ ),
],
};
}

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 30, 12:31 AM (6 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2203176
Default Alt Text
D13291.diff (1 KB)

Event Timeline