From fdc6082c834daedf48453405c969e1cde30e2481 Mon Sep 17 00:00:00 2001 From: Germain Date: Thu, 23 Dec 2021 10:12:27 +0000 Subject: [PATCH] Make threads events indexed by the index manager (#7442) --- src/components/structures/ThreadView.tsx | 11 +---------- src/utils/EventUtils.ts | 9 +-------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/components/structures/ThreadView.tsx b/src/components/structures/ThreadView.tsx index f7179525ef6..e53394ad082 100644 --- a/src/components/structures/ThreadView.tsx +++ b/src/components/structures/ThreadView.tsx @@ -135,16 +135,7 @@ export default class ThreadView extends React.Component { private setupThread = (mxEv: MatrixEvent) => { let thread = this.props.room.threads.get(mxEv.getId()); if (!thread) { - const client = MatrixClientPeg.get(); - // Do not attach this thread object to the event for now - // TODO: When local echo gets reintroduced it will be important - // to add that back in, and the threads model should go through the - // same reconciliation algorithm as events - thread = new Thread( - [mxEv], - this.props.room, - client, - ); + thread = this.props.room.createThread([mxEv]); } thread.on(ThreadEvent.Update, this.updateThread); thread.once(ThreadEvent.Ready, this.updateThread); diff --git a/src/utils/EventUtils.ts b/src/utils/EventUtils.ts index 95ee1b14c69..8c7731f2b81 100644 --- a/src/utils/EventUtils.ts +++ b/src/utils/EventUtils.ts @@ -17,7 +17,6 @@ limitations under the License. import { EventStatus, MatrixEvent } from 'matrix-js-sdk/src/models/event'; import { EventType, MsgType, RelationType } from "matrix-js-sdk/src/@types/event"; import { MatrixClient } from 'matrix-js-sdk/src/client'; -import { Thread } from 'matrix-js-sdk/src/models/thread'; import { logger } from 'matrix-js-sdk/src/logger'; import { POLL_START_EVENT_TYPE } from "matrix-js-sdk/src/@types/polls"; @@ -194,13 +193,7 @@ export async function fetchInitialEvent( const rootEventData = await client.fetchRoomEvent(roomId, initialEvent.threadRootId); const rootEvent = new MatrixEvent(rootEventData); const room = client.getRoom(roomId); - const thread = new Thread( - [rootEvent], - room, - client, - ); - thread.addEvent(initialEvent); - room.threads.set(thread.id, thread); + room.createThread([rootEvent]); } catch (e) { logger.warn("Could not find root event: " + initialEvent.threadRootId); }