Make threads events indexed by the index manager (#7442)

This commit is contained in:
Germain 2021-12-23 10:12:27 +00:00 committed by GitHub
parent defbe16448
commit fdc6082c83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 18 deletions

View file

@ -135,16 +135,7 @@ export default class ThreadView extends React.Component<IProps, IState> {
private setupThread = (mxEv: MatrixEvent) => { private setupThread = (mxEv: MatrixEvent) => {
let thread = this.props.room.threads.get(mxEv.getId()); let thread = this.props.room.threads.get(mxEv.getId());
if (!thread) { if (!thread) {
const client = MatrixClientPeg.get(); thread = this.props.room.createThread([mxEv]);
// 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.on(ThreadEvent.Update, this.updateThread); thread.on(ThreadEvent.Update, this.updateThread);
thread.once(ThreadEvent.Ready, this.updateThread); thread.once(ThreadEvent.Ready, this.updateThread);

View file

@ -17,7 +17,6 @@ limitations under the License.
import { EventStatus, MatrixEvent } from 'matrix-js-sdk/src/models/event'; import { EventStatus, MatrixEvent } from 'matrix-js-sdk/src/models/event';
import { EventType, MsgType, RelationType } from "matrix-js-sdk/src/@types/event"; import { EventType, MsgType, RelationType } from "matrix-js-sdk/src/@types/event";
import { MatrixClient } from 'matrix-js-sdk/src/client'; 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 { logger } from 'matrix-js-sdk/src/logger';
import { POLL_START_EVENT_TYPE } from "matrix-js-sdk/src/@types/polls"; 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 rootEventData = await client.fetchRoomEvent(roomId, initialEvent.threadRootId);
const rootEvent = new MatrixEvent(rootEventData); const rootEvent = new MatrixEvent(rootEventData);
const room = client.getRoom(roomId); const room = client.getRoom(roomId);
const thread = new Thread( room.createThread([rootEvent]);
[rootEvent],
room,
client,
);
thread.addEvent(initialEvent);
room.threads.set(thread.id, thread);
} catch (e) { } catch (e) {
logger.warn("Could not find root event: " + initialEvent.threadRootId); logger.warn("Could not find root event: " + initialEvent.threadRootId);
} }