Skip to content

Commit 540514c

Browse files
authored
Update threads handling for replies-to-thread-responses as per MSC update (matrix-org#2305)
* Update threads handling for replies-to-thread-responses as per MSC update * Update tests to match new behaviour
1 parent db58a66 commit 540514c

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

spec/integ/matrix-client-methods.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ describe("MatrixClient", function() {
797797
]);
798798
});
799799

800-
it("sends reply to thread responses to thread timeline only", () => {
800+
it("sends reply to thread responses to main timeline only", () => {
801801
client.clientOpts = { experimentalThreadSupport: true };
802802

803803
const threadRootEvent = buildEventPollStartThreadRoot();
@@ -814,12 +814,12 @@ describe("MatrixClient", function() {
814814

815815
expect(timeline).toEqual([
816816
threadRootEvent,
817+
replyToThreadResponse,
817818
]);
818819

819820
expect(threaded).toEqual([
820821
threadRootEvent,
821822
eventMessageInThread,
822-
replyToThreadResponse,
823823
]);
824824
});
825825
});

spec/unit/room.spec.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,36 +2154,32 @@ describe("Room", function() {
21542154
expect(room.eventShouldLiveIn(threadReaction2Redaction, events, roots).threadId).toBe(threadRoot.getId());
21552155
});
21562156

2157-
it("reply to thread response and its relations&redactions should be only in thread timeline", () => {
2157+
it("reply to thread response and its relations&redactions should be only in main timeline", () => {
21582158
const threadRoot = mkMessage();
21592159
const threadResponse1 = mkThreadResponse(threadRoot);
21602160
const reply1 = mkReply(threadResponse1);
2161-
const threadReaction1 = mkReaction(reply1);
2162-
const threadReaction2 = mkReaction(reply1);
2163-
const threadReaction2Redaction = mkRedaction(reply1);
2161+
const reaction1 = mkReaction(reply1);
2162+
const reaction2 = mkReaction(reply1);
2163+
const reaction2Redaction = mkRedaction(reply1);
21642164

21652165
const roots = new Set([threadRoot.getId()]);
21662166
const events = [
21672167
threadRoot,
21682168
threadResponse1,
21692169
reply1,
2170-
threadReaction1,
2171-
threadReaction2,
2172-
threadReaction2Redaction,
2170+
reaction1,
2171+
reaction2,
2172+
reaction2Redaction,
21732173
];
21742174

2175-
expect(room.eventShouldLiveIn(reply1, events, roots).shouldLiveInRoom).toBeFalsy();
2176-
expect(room.eventShouldLiveIn(reply1, events, roots).shouldLiveInThread).toBeTruthy();
2177-
expect(room.eventShouldLiveIn(reply1, events, roots).threadId).toBe(threadRoot.getId());
2178-
expect(room.eventShouldLiveIn(threadReaction1, events, roots).shouldLiveInRoom).toBeFalsy();
2179-
expect(room.eventShouldLiveIn(threadReaction1, events, roots).shouldLiveInThread).toBeTruthy();
2180-
expect(room.eventShouldLiveIn(threadReaction1, events, roots).threadId).toBe(threadRoot.getId());
2181-
expect(room.eventShouldLiveIn(threadReaction2, events, roots).shouldLiveInRoom).toBeFalsy();
2182-
expect(room.eventShouldLiveIn(threadReaction2, events, roots).shouldLiveInThread).toBeTruthy();
2183-
expect(room.eventShouldLiveIn(threadReaction2, events, roots).threadId).toBe(threadRoot.getId());
2184-
expect(room.eventShouldLiveIn(threadReaction2Redaction, events, roots).shouldLiveInRoom).toBeFalsy();
2185-
expect(room.eventShouldLiveIn(threadReaction2Redaction, events, roots).shouldLiveInThread).toBeTruthy();
2186-
expect(room.eventShouldLiveIn(threadReaction2Redaction, events, roots).threadId).toBe(threadRoot.getId());
2175+
expect(room.eventShouldLiveIn(reply1, events, roots).shouldLiveInRoom).toBeTruthy();
2176+
expect(room.eventShouldLiveIn(reply1, events, roots).shouldLiveInThread).toBeFalsy();
2177+
expect(room.eventShouldLiveIn(reaction1, events, roots).shouldLiveInRoom).toBeTruthy();
2178+
expect(room.eventShouldLiveIn(reaction1, events, roots).shouldLiveInThread).toBeFalsy();
2179+
expect(room.eventShouldLiveIn(reaction2, events, roots).shouldLiveInRoom).toBeTruthy();
2180+
expect(room.eventShouldLiveIn(reaction2, events, roots).shouldLiveInThread).toBeFalsy();
2181+
expect(room.eventShouldLiveIn(reaction2Redaction, events, roots).shouldLiveInRoom).toBeTruthy();
2182+
expect(room.eventShouldLiveIn(reaction2Redaction, events, roots).shouldLiveInThread).toBeFalsy();
21872183
});
21882184

21892185
it("reply to reply to thread root should only be in the main timeline", () => {

src/models/room.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,16 +1612,6 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>
16121612
};
16131613
}
16141614

1615-
// A reply directly to a thread response is shown as part of the thread only, this is to provide a better
1616-
// experience when communicating with users using clients without full threads support
1617-
if (parentEvent?.isThreadRelation) {
1618-
return {
1619-
shouldLiveInRoom: false,
1620-
shouldLiveInThread: true,
1621-
threadId: parentEvent.threadRootId,
1622-
};
1623-
}
1624-
16251615
// We've exhausted all scenarios, can safely assume that this event should live in the room timeline only
16261616
return {
16271617
shouldLiveInRoom: true,

0 commit comments

Comments
 (0)