Skip to content

Commit bbd8d05

Browse files
justjannegithub-actions[bot]
authored andcommitted
Threads are missing from the timeline (#2996)
(cherry picked from commit 4f86eee)
1 parent 6cc8e44 commit bbd8d05

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

spec/integ/matrix-client-event-timeline.spec.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,61 @@ describe("MatrixClient event timelines", function () {
10161016
httpBackend.flushAllExpected(),
10171017
]);
10181018
});
1019+
1020+
it("should create threads for thread roots discovered", function () {
1021+
const room = client.getRoom(roomId)!;
1022+
const timelineSet = room.getTimelineSets()[0];
1023+
1024+
httpBackend
1025+
.when("GET", "/rooms/!foo%3Abar/context/" + encodeURIComponent(EVENTS[0].event_id!))
1026+
.respond(200, function () {
1027+
return {
1028+
start: "start_token0",
1029+
events_before: [],
1030+
event: EVENTS[0],
1031+
events_after: [],
1032+
end: "end_token0",
1033+
state: [],
1034+
};
1035+
});
1036+
1037+
httpBackend
1038+
.when("GET", "/rooms/!foo%3Abar/messages")
1039+
.check(function (req) {
1040+
const params = req.queryParams!;
1041+
expect(params.dir).toEqual("b");
1042+
expect(params.from).toEqual("start_token0");
1043+
expect(params.limit).toEqual("30");
1044+
})
1045+
.respond(200, function () {
1046+
return {
1047+
chunk: [EVENTS[1], EVENTS[2], THREAD_ROOT],
1048+
end: "start_token1",
1049+
};
1050+
});
1051+
1052+
let tl: EventTimeline;
1053+
return Promise.all([
1054+
client
1055+
.getEventTimeline(timelineSet, EVENTS[0].event_id!)
1056+
.then(function (tl0) {
1057+
tl = tl0!;
1058+
return client.paginateEventTimeline(tl, { backwards: true });
1059+
})
1060+
.then(function (success) {
1061+
expect(success).toBeTruthy();
1062+
expect(tl!.getEvents().length).toEqual(4);
1063+
expect(tl!.getEvents()[0].event).toEqual(THREAD_ROOT);
1064+
expect(tl!.getEvents()[1].event).toEqual(EVENTS[2]);
1065+
expect(tl!.getEvents()[2].event).toEqual(EVENTS[1]);
1066+
expect(tl!.getEvents()[3].event).toEqual(EVENTS[0]);
1067+
expect(room.getThreads().map((it) => it.id)).toEqual([THREAD_ROOT.event_id!]);
1068+
expect(tl!.getPaginationToken(EventTimeline.BACKWARDS)).toEqual("start_token1");
1069+
expect(tl!.getPaginationToken(EventTimeline.FORWARDS)).toEqual("end_token0");
1070+
}),
1071+
httpBackend.flushAllExpected(),
1072+
]);
1073+
});
10191074
});
10201075

10211076
describe("paginateEventTimeline for thread list timeline", function () {

src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5951,7 +5951,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
59515951
this.processBeaconEvents(room, timelineEvents);
59525952
this.processThreadRoots(
59535953
room,
5954-
timelineEvents.filter((it) => it.isRelation(THREAD_RELATION_TYPE.name)),
5954+
timelineEvents.filter((it) => it.getServerAggregatedRelation(THREAD_RELATION_TYPE.name)),
59555955
false,
59565956
);
59575957

0 commit comments

Comments
 (0)