Skip to content

Commit c3d7a49

Browse files
authored
Stop tracking threads if threads support is disabled (#2295)
1 parent 9aab917 commit c3d7a49

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ describe("MatrixClient event timelines", function() {
496496
});
497497

498498
it("should handle thread replies with server support by fetching a contiguous thread timeline", async () => {
499+
client.clientOpts.experimentalThreadSupport = true;
499500
Thread.setServerSideSupport(true);
500501
client.stopClient(); // we don't need the client to be syncing at this time
501502
const room = client.getRoom(roomId);

src/client.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -3776,7 +3776,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
37763776
const thread = room?.threads.get(threadId);
37773777
if (thread) {
37783778
localEvent.setThread(thread);
3779-
localEvent.setThreadId(thread.id);
37803779
}
37813780

37823781
// set up re-emitter for this new event - this is normally the job of EventMapper but we don't use it here
@@ -5278,7 +5277,10 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
52785277
// Where the event is a thread reply (not a root) and running in MSC-enabled mode the Thread timeline only
52795278
// functions contiguously, so we have to jump through some hoops to get our target event in it.
52805279
// XXX: workaround for https://github.com/vector-im/element-meta/issues/150
5281-
if (Thread.hasServerSideSupport && event.isRelation(THREAD_RELATION_TYPE.name)) {
5280+
if (Thread.hasServerSideSupport &&
5281+
this.supportsExperimentalThreads() &&
5282+
event.isRelation(THREAD_RELATION_TYPE.name)
5283+
) {
52825284
const [, threadedEvents] = timelineSet.room.partitionThreadedEvents(events);
52835285
const thread = await timelineSet.room.createThreadFetchRoot(event.threadRootId, threadedEvents, true);
52845286

src/models/room.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>
14741474
public threadsReady = false;
14751475

14761476
public async fetchRoomThreads(): Promise<void> {
1477-
if (this.threadsReady) {
1477+
if (this.threadsReady || !this.client.supportsExperimentalThreads()) {
14781478
return;
14791479
}
14801480

@@ -1662,7 +1662,7 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>
16621662
// benefit from all the APIs a homeserver can provide to enhance the thread experience
16631663
thread = this.createThread(rootEvent, events, toStartOfTimeline);
16641664
if (thread) {
1665-
rootEvent.setThread(thread);
1665+
rootEvent?.setThread(thread);
16661666
}
16671667
deferred.resolve(thread);
16681668
}

0 commit comments

Comments
 (0)