You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-07 05:22:15 +03:00
Make threads events indexed by the index manager (#2089)
This commit is contained in:
@@ -1337,10 +1337,7 @@ export class Room extends EventEmitter {
|
||||
rootEvent = new MatrixEvent(eventData);
|
||||
}
|
||||
events.unshift(rootEvent);
|
||||
thread = new Thread(events, this, this.client);
|
||||
this.threads.set(thread.id, thread);
|
||||
this.reEmitter.reEmit(thread, [ThreadEvent.Update, ThreadEvent.Ready]);
|
||||
this.emit(ThreadEvent.New, thread);
|
||||
thread = this.createThread(events);
|
||||
}
|
||||
|
||||
if (event.getUnsigned().transaction_id) {
|
||||
@@ -1355,6 +1352,19 @@ export class Room extends EventEmitter {
|
||||
this.emit(ThreadEvent.Update, thread);
|
||||
}
|
||||
|
||||
public createThread(events: MatrixEvent[]): Thread {
|
||||
const thread = new Thread(events, this, this.client);
|
||||
this.threads.set(thread.id, thread);
|
||||
this.reEmitter.reEmit(thread, [
|
||||
ThreadEvent.Update,
|
||||
ThreadEvent.Ready,
|
||||
"Room.timeline",
|
||||
"Room.timelineReset",
|
||||
]);
|
||||
this.emit(ThreadEvent.New, thread);
|
||||
return thread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an event to the end of this room's live timelines. Will fire
|
||||
* "Room.timeline".
|
||||
|
||||
@@ -15,6 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
import { MatrixClient } from "../matrix";
|
||||
import { ReEmitter } from "../ReEmitter";
|
||||
import { MatrixEvent } from "./event";
|
||||
import { EventTimeline } from "./event-timeline";
|
||||
import { EventTimelineSet } from './event-timeline-set';
|
||||
@@ -44,6 +45,8 @@ export class Thread extends TypedEventEmitter<ThreadEvent> {
|
||||
|
||||
private _currentUserParticipated = false;
|
||||
|
||||
private reEmitter: ReEmitter;
|
||||
|
||||
constructor(
|
||||
events: MatrixEvent[] = [],
|
||||
public readonly room: Room,
|
||||
@@ -54,11 +57,19 @@ export class Thread extends TypedEventEmitter<ThreadEvent> {
|
||||
throw new Error("Can't create an empty thread");
|
||||
}
|
||||
|
||||
this.reEmitter = new ReEmitter(this);
|
||||
|
||||
this.timelineSet = new EventTimelineSet(this.room, {
|
||||
unstableClientRelationAggregation: true,
|
||||
timelineSupport: true,
|
||||
pendingEvents: true,
|
||||
});
|
||||
|
||||
this.reEmitter.reEmit(this.timelineSet, [
|
||||
"Room.timeline",
|
||||
"Room.timelineReset",
|
||||
]);
|
||||
|
||||
events.forEach(event => this.addEvent(event));
|
||||
|
||||
room.on("Room.localEchoUpdated", this.onEcho);
|
||||
|
||||
Reference in New Issue
Block a user