From d151365fd751400c72a3eb18b964af140457bdf7 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 13 Apr 2022 16:41:40 +0100 Subject: [PATCH] Stop tracking threads if threads support is disabled (#8308) --- src/components/structures/RoomView.tsx | 20 +++++++++++--------- src/utils/EventUtils.ts | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 1d363b649e..321c598ea6 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -1395,15 +1395,17 @@ export class RoomView extends React.Component { return b.length - a.length; }); - // Process all thread roots returned in this batch of search results - // XXX: This won't work for results coming from Seshat which won't include the bundled relationship - for (const result of results.results) { - for (const event of result.context.getTimeline()) { - const bundledRelationship = event - .getServerAggregatedRelation(THREAD_RELATION_TYPE.name); - if (!bundledRelationship || event.getThread()) continue; - const room = this.context.getRoom(event.getRoomId()); - event.setThread(room.findThreadForEvent(event) ?? room.createThread(event, [], true)); + if (this.context.supportsExperimentalThreads()) { + // Process all thread roots returned in this batch of search results + // XXX: This won't work for results coming from Seshat which won't include the bundled relationship + for (const result of results.results) { + for (const event of result.context.getTimeline()) { + const bundledRelationship = event + .getServerAggregatedRelation(THREAD_RELATION_TYPE.name); + if (!bundledRelationship || event.getThread()) continue; + const room = this.context.getRoom(event.getRoomId()); + event.setThread(room.findThreadForEvent(event) ?? room.createThread(event, [], true)); + } } } diff --git a/src/utils/EventUtils.ts b/src/utils/EventUtils.ts index 49ec5c29b3..afcfc41139 100644 --- a/src/utils/EventUtils.ts +++ b/src/utils/EventUtils.ts @@ -217,7 +217,7 @@ export async function fetchInitialEvent( initialEvent = null; } - if (initialEvent?.isThreadRelation) { + if (initialEvent?.isThreadRelation && client.supportsExperimentalThreads()) { try { const rootEventData = await client.fetchRoomEvent(roomId, initialEvent.threadRootId); const rootEvent = new MatrixEvent(rootEventData);