From 88ba4fad716a17f6c4331d2b91c8148d08064df3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 31 Jul 2023 19:16:42 +0100 Subject: [PATCH] Skip processing thread roots and fetching threads list when support is disabled (#3642) * Skip processing thread roots and fetching threads list when support is disabled * Enable threads support in tests --- spec/integ/matrix-client-event-timeline.spec.ts | 2 +- src/client.ts | 1 + src/models/room.ts | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/integ/matrix-client-event-timeline.spec.ts b/spec/integ/matrix-client-event-timeline.spec.ts index 254dff47f..26e968d71 100644 --- a/spec/integ/matrix-client-event-timeline.spec.ts +++ b/spec/integ/matrix-client-event-timeline.spec.ts @@ -207,7 +207,7 @@ function startClient(httpBackend: HttpBackend, client: MatrixClient) { httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" }); httpBackend.when("GET", "/sync").respond(200, INITIAL_SYNC_DATA); - client.startClient(); + client.startClient({ threadSupport: true }); // set up a promise which will resolve once the client is initialised const prom = new Promise((resolve) => { diff --git a/src/client.ts b/src/client.ts index ea17dfb83..21f946931 100644 --- a/src/client.ts +++ b/src/client.ts @@ -9771,6 +9771,7 @@ export class MatrixClient extends TypedEventEmitter { * Takes the given thread root events and creates threads for them. */ public processThreadRoots(events: MatrixEvent[], toStartOfTimeline: boolean): void { + if (!this.client.supportsThreads()) return; for (const rootEvent of events) { EventTimeline.setEventMetadata(rootEvent, this.currentState, toStartOfTimeline); if (!this.getThread(rootEvent.getId()!)) { @@ -2031,6 +2032,7 @@ export class Room extends ReadReceipt { * @internal */ private async fetchRoomThreadList(filter?: ThreadFilterType): Promise { + if (!this.client.supportsThreads()) return; if (this.threadsTimelineSets.length === 0) return; const timelineSet = filter === ThreadFilterType.My ? this.threadsTimelineSets[1] : this.threadsTimelineSets[0];