Skip to content

Commit

Permalink
Threads are missing from the timeline (#2996)
Browse files Browse the repository at this point in the history
  • Loading branch information
justjanne authored Dec 19, 2022
1 parent 618242e commit 4f86eee
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
55 changes: 55 additions & 0 deletions spec/integ/matrix-client-event-timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,61 @@ describe("MatrixClient event timelines", function () {
httpBackend.flushAllExpected(),
]);
});

it("should create threads for thread roots discovered", function () {
const room = client.getRoom(roomId)!;
const timelineSet = room.getTimelineSets()[0];

httpBackend
.when("GET", "/rooms/!foo%3Abar/context/" + encodeURIComponent(EVENTS[0].event_id!))
.respond(200, function () {
return {
start: "start_token0",
events_before: [],
event: EVENTS[0],
events_after: [],
end: "end_token0",
state: [],
};
});

httpBackend
.when("GET", "/rooms/!foo%3Abar/messages")
.check(function (req) {
const params = req.queryParams!;
expect(params.dir).toEqual("b");
expect(params.from).toEqual("start_token0");
expect(params.limit).toEqual("30");
})
.respond(200, function () {
return {
chunk: [EVENTS[1], EVENTS[2], THREAD_ROOT],
end: "start_token1",
};
});

let tl: EventTimeline;
return Promise.all([
client
.getEventTimeline(timelineSet, EVENTS[0].event_id!)
.then(function (tl0) {
tl = tl0!;
return client.paginateEventTimeline(tl, { backwards: true });
})
.then(function (success) {
expect(success).toBeTruthy();
expect(tl!.getEvents().length).toEqual(4);
expect(tl!.getEvents()[0].event).toEqual(THREAD_ROOT);
expect(tl!.getEvents()[1].event).toEqual(EVENTS[2]);
expect(tl!.getEvents()[2].event).toEqual(EVENTS[1]);
expect(tl!.getEvents()[3].event).toEqual(EVENTS[0]);
expect(room.getThreads().map((it) => it.id)).toEqual([THREAD_ROOT.event_id!]);
expect(tl!.getPaginationToken(EventTimeline.BACKWARDS)).toEqual("start_token1");
expect(tl!.getPaginationToken(EventTimeline.FORWARDS)).toEqual("end_token0");
}),
httpBackend.flushAllExpected(),
]);
});
});

it("should ensure thread events are ordered correctly", async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6059,7 +6059,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
this.processBeaconEvents(room, timelineEvents);
this.processThreadRoots(
room,
timelineEvents.filter((it) => it.isRelation(THREAD_RELATION_TYPE.name)),
timelineEvents.filter((it) => it.getServerAggregatedRelation(THREAD_RELATION_TYPE.name)),
false,
);

Expand Down

0 comments on commit 4f86eee

Please sign in to comment.