You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-04 05:02:41 +03:00
Don't decrement the length count of a thread when root redacted (#2314)
This commit is contained in:
committed by
GitHub
parent
c0cb66233a
commit
e133005b44
@@ -2046,6 +2046,42 @@ describe("Room", function() {
|
||||
expect(thread.replyToEvent.getId()).toBe(threadResponse2.getId());
|
||||
});
|
||||
|
||||
it("should not decrement the length when the thread root is redacted", async () => {
|
||||
room.client.supportsExperimentalThreads = () => true;
|
||||
|
||||
const threadRoot = mkMessage();
|
||||
const threadResponse1 = mkThreadResponse(threadRoot);
|
||||
threadResponse1.localTimestamp += 1000;
|
||||
const threadResponse2 = mkThreadResponse(threadRoot);
|
||||
threadResponse2.localTimestamp += 2000;
|
||||
const threadResponse2Reaction = mkReaction(threadResponse2);
|
||||
|
||||
room.client.fetchRoomEvent = (eventId: string) => Promise.resolve({
|
||||
...threadRoot.event,
|
||||
unsigned: {
|
||||
"age": 123,
|
||||
"m.relations": {
|
||||
"m.thread": {
|
||||
latest_event: threadResponse2.event,
|
||||
count: 2,
|
||||
current_user_participated: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
room.addLiveEvents([threadRoot, threadResponse1, threadResponse2, threadResponse2Reaction]);
|
||||
const thread = await emitPromise(room, ThreadEvent.New);
|
||||
|
||||
expect(thread).toHaveLength(2);
|
||||
expect(thread.replyToEvent.getId()).toBe(threadResponse2.getId());
|
||||
|
||||
const threadRootRedaction = mkRedaction(threadRoot);
|
||||
room.addLiveEvents([threadRootRedaction]);
|
||||
await emitPromise(thread, ThreadEvent.Update);
|
||||
expect(thread).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("Redacting the lastEvent finds a new lastEvent", async () => {
|
||||
room.client.supportsExperimentalThreads = () => true;
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ export class Thread extends TypedEventEmitter<EmittedEvents, EventHandlerMap> {
|
||||
private onBeforeRedaction = (event: MatrixEvent, redaction: MatrixEvent) => {
|
||||
if (event?.isRelation(THREAD_RELATION_TYPE.name) &&
|
||||
this.room.eventShouldLiveIn(event).threadId === this.id &&
|
||||
event.getId() !== this.id && // the root event isn't counted in the length so ignore this redaction
|
||||
!redaction.status // only respect it when it succeeds
|
||||
) {
|
||||
this.replyCount--;
|
||||
|
||||
Reference in New Issue
Block a user