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);
|
rootEvent = new MatrixEvent(eventData);
|
||||||
}
|
}
|
||||||
events.unshift(rootEvent);
|
events.unshift(rootEvent);
|
||||||
thread = new Thread(events, this, this.client);
|
thread = this.createThread(events);
|
||||||
this.threads.set(thread.id, thread);
|
|
||||||
this.reEmitter.reEmit(thread, [ThreadEvent.Update, ThreadEvent.Ready]);
|
|
||||||
this.emit(ThreadEvent.New, thread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getUnsigned().transaction_id) {
|
if (event.getUnsigned().transaction_id) {
|
||||||
@@ -1355,6 +1352,19 @@ export class Room extends EventEmitter {
|
|||||||
this.emit(ThreadEvent.Update, thread);
|
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
|
* Add an event to the end of this room's live timelines. Will fire
|
||||||
* "Room.timeline".
|
* "Room.timeline".
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { MatrixClient } from "../matrix";
|
import { MatrixClient } from "../matrix";
|
||||||
|
import { ReEmitter } from "../ReEmitter";
|
||||||
import { MatrixEvent } from "./event";
|
import { MatrixEvent } from "./event";
|
||||||
import { EventTimeline } from "./event-timeline";
|
import { EventTimeline } from "./event-timeline";
|
||||||
import { EventTimelineSet } from './event-timeline-set';
|
import { EventTimelineSet } from './event-timeline-set';
|
||||||
@@ -44,6 +45,8 @@ export class Thread extends TypedEventEmitter<ThreadEvent> {
|
|||||||
|
|
||||||
private _currentUserParticipated = false;
|
private _currentUserParticipated = false;
|
||||||
|
|
||||||
|
private reEmitter: ReEmitter;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
events: MatrixEvent[] = [],
|
events: MatrixEvent[] = [],
|
||||||
public readonly room: Room,
|
public readonly room: Room,
|
||||||
@@ -54,11 +57,19 @@ export class Thread extends TypedEventEmitter<ThreadEvent> {
|
|||||||
throw new Error("Can't create an empty thread");
|
throw new Error("Can't create an empty thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.reEmitter = new ReEmitter(this);
|
||||||
|
|
||||||
this.timelineSet = new EventTimelineSet(this.room, {
|
this.timelineSet = new EventTimelineSet(this.room, {
|
||||||
unstableClientRelationAggregation: true,
|
unstableClientRelationAggregation: true,
|
||||||
timelineSupport: true,
|
timelineSupport: true,
|
||||||
pendingEvents: true,
|
pendingEvents: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.reEmitter.reEmit(this.timelineSet, [
|
||||||
|
"Room.timeline",
|
||||||
|
"Room.timelineReset",
|
||||||
|
]);
|
||||||
|
|
||||||
events.forEach(event => this.addEvent(event));
|
events.forEach(event => this.addEvent(event));
|
||||||
|
|
||||||
room.on("Room.localEchoUpdated", this.onEcho);
|
room.on("Room.localEchoUpdated", this.onEcho);
|
||||||
|
|||||||
Reference in New Issue
Block a user