1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-10 21:23:02 +03:00

Factor out the code for moving an event to the main timeline

This commit is contained in:
Andy Balaam
2023-10-17 12:47:21 +01:00
parent 43a0dc56e1
commit 942dfcb84b

View File

@@ -1195,22 +1195,24 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
// If the redacted event was in a thread // If the redacted event was in a thread
if (room && this.threadRootId && this.threadRootId !== this.getId()) { if (room && this.threadRootId && this.threadRootId !== this.getId()) {
// Remove it from its thread this.moveToMainTimeline(room);
this.thread?.timelineSet.removeEvent(this.getId()!);
this.setThread(undefined);
// And insert it into the main timeline
const timeline = room.getLiveTimeline();
// We use insertEventIntoTimeline to insert it in timestamp order,
// because we don't know where it should go (until we have MSC4033).
timeline
.getTimelineSet()
.insertEventIntoTimeline(this, timeline, timeline.getState(EventTimeline.FORWARDS)!);
} }
this.invalidateExtensibleEvent(); this.invalidateExtensibleEvent();
} }
private moveToMainTimeline(room: Room): void {
// Remove it from its thread
this.thread?.timelineSet.removeEvent(this.getId()!);
this.setThread(undefined);
// And insert it into the main timeline
const timeline = room.getLiveTimeline();
// We use insertEventIntoTimeline to insert it in timestamp order,
// because we don't know where it should go (until we have MSC4033).
timeline.getTimelineSet().insertEventIntoTimeline(this, timeline, timeline.getState(EventTimeline.FORWARDS)!);
}
/** /**
* Check if this event has been redacted * Check if this event has been redacted
* *