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
Update threads handling for replies-to-thread-responses as per MSC update (#2305)
* Update threads handling for replies-to-thread-responses as per MSC update * Update tests to match new behaviour
This commit is contained in:
committed by
GitHub
parent
db58a66e19
commit
540514c805
@@ -797,7 +797,7 @@ describe("MatrixClient", function() {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sends reply to thread responses to thread timeline only", () => {
|
it("sends reply to thread responses to main timeline only", () => {
|
||||||
client.clientOpts = { experimentalThreadSupport: true };
|
client.clientOpts = { experimentalThreadSupport: true };
|
||||||
|
|
||||||
const threadRootEvent = buildEventPollStartThreadRoot();
|
const threadRootEvent = buildEventPollStartThreadRoot();
|
||||||
@@ -814,12 +814,12 @@ describe("MatrixClient", function() {
|
|||||||
|
|
||||||
expect(timeline).toEqual([
|
expect(timeline).toEqual([
|
||||||
threadRootEvent,
|
threadRootEvent,
|
||||||
|
replyToThreadResponse,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(threaded).toEqual([
|
expect(threaded).toEqual([
|
||||||
threadRootEvent,
|
threadRootEvent,
|
||||||
eventMessageInThread,
|
eventMessageInThread,
|
||||||
replyToThreadResponse,
|
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2154,36 +2154,32 @@ describe("Room", function() {
|
|||||||
expect(room.eventShouldLiveIn(threadReaction2Redaction, events, roots).threadId).toBe(threadRoot.getId());
|
expect(room.eventShouldLiveIn(threadReaction2Redaction, events, roots).threadId).toBe(threadRoot.getId());
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reply to thread response and its relations&redactions should be only in thread timeline", () => {
|
it("reply to thread response and its relations&redactions should be only in main timeline", () => {
|
||||||
const threadRoot = mkMessage();
|
const threadRoot = mkMessage();
|
||||||
const threadResponse1 = mkThreadResponse(threadRoot);
|
const threadResponse1 = mkThreadResponse(threadRoot);
|
||||||
const reply1 = mkReply(threadResponse1);
|
const reply1 = mkReply(threadResponse1);
|
||||||
const threadReaction1 = mkReaction(reply1);
|
const reaction1 = mkReaction(reply1);
|
||||||
const threadReaction2 = mkReaction(reply1);
|
const reaction2 = mkReaction(reply1);
|
||||||
const threadReaction2Redaction = mkRedaction(reply1);
|
const reaction2Redaction = mkRedaction(reply1);
|
||||||
|
|
||||||
const roots = new Set([threadRoot.getId()]);
|
const roots = new Set([threadRoot.getId()]);
|
||||||
const events = [
|
const events = [
|
||||||
threadRoot,
|
threadRoot,
|
||||||
threadResponse1,
|
threadResponse1,
|
||||||
reply1,
|
reply1,
|
||||||
threadReaction1,
|
reaction1,
|
||||||
threadReaction2,
|
reaction2,
|
||||||
threadReaction2Redaction,
|
reaction2Redaction,
|
||||||
];
|
];
|
||||||
|
|
||||||
expect(room.eventShouldLiveIn(reply1, events, roots).shouldLiveInRoom).toBeFalsy();
|
expect(room.eventShouldLiveIn(reply1, events, roots).shouldLiveInRoom).toBeTruthy();
|
||||||
expect(room.eventShouldLiveIn(reply1, events, roots).shouldLiveInThread).toBeTruthy();
|
expect(room.eventShouldLiveIn(reply1, events, roots).shouldLiveInThread).toBeFalsy();
|
||||||
expect(room.eventShouldLiveIn(reply1, events, roots).threadId).toBe(threadRoot.getId());
|
expect(room.eventShouldLiveIn(reaction1, events, roots).shouldLiveInRoom).toBeTruthy();
|
||||||
expect(room.eventShouldLiveIn(threadReaction1, events, roots).shouldLiveInRoom).toBeFalsy();
|
expect(room.eventShouldLiveIn(reaction1, events, roots).shouldLiveInThread).toBeFalsy();
|
||||||
expect(room.eventShouldLiveIn(threadReaction1, events, roots).shouldLiveInThread).toBeTruthy();
|
expect(room.eventShouldLiveIn(reaction2, events, roots).shouldLiveInRoom).toBeTruthy();
|
||||||
expect(room.eventShouldLiveIn(threadReaction1, events, roots).threadId).toBe(threadRoot.getId());
|
expect(room.eventShouldLiveIn(reaction2, events, roots).shouldLiveInThread).toBeFalsy();
|
||||||
expect(room.eventShouldLiveIn(threadReaction2, events, roots).shouldLiveInRoom).toBeFalsy();
|
expect(room.eventShouldLiveIn(reaction2Redaction, events, roots).shouldLiveInRoom).toBeTruthy();
|
||||||
expect(room.eventShouldLiveIn(threadReaction2, events, roots).shouldLiveInThread).toBeTruthy();
|
expect(room.eventShouldLiveIn(reaction2Redaction, events, roots).shouldLiveInThread).toBeFalsy();
|
||||||
expect(room.eventShouldLiveIn(threadReaction2, events, roots).threadId).toBe(threadRoot.getId());
|
|
||||||
expect(room.eventShouldLiveIn(threadReaction2Redaction, events, roots).shouldLiveInRoom).toBeFalsy();
|
|
||||||
expect(room.eventShouldLiveIn(threadReaction2Redaction, events, roots).shouldLiveInThread).toBeTruthy();
|
|
||||||
expect(room.eventShouldLiveIn(threadReaction2Redaction, events, roots).threadId).toBe(threadRoot.getId());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reply to reply to thread root should only be in the main timeline", () => {
|
it("reply to reply to thread root should only be in the main timeline", () => {
|
||||||
|
|||||||
@@ -1612,16 +1612,6 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// A reply directly to a thread response is shown as part of the thread only, this is to provide a better
|
|
||||||
// experience when communicating with users using clients without full threads support
|
|
||||||
if (parentEvent?.isThreadRelation) {
|
|
||||||
return {
|
|
||||||
shouldLiveInRoom: false,
|
|
||||||
shouldLiveInThread: true,
|
|
||||||
threadId: parentEvent.threadRootId,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// We've exhausted all scenarios, can safely assume that this event should live in the room timeline only
|
// We've exhausted all scenarios, can safely assume that this event should live in the room timeline only
|
||||||
return {
|
return {
|
||||||
shouldLiveInRoom: true,
|
shouldLiveInRoom: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user