This commit is contained in:
Jaiwanth 2021-06-03 13:21:56 +05:30
parent 183166c460
commit 4c22d1f2a1
3 changed files with 55 additions and 52 deletions

View file

@ -1,7 +1,36 @@
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { Room } from "matrix-js-sdk/src/models/room";
import { MatrixClientPeg } from "../../MatrixClientPeg";
import { TimelineWindow } from "matrix-js-sdk/src/timeline-window";
import { arrayFastClone } from "../arrays";
export abstract class Exporter {
constructor(protected res: MatrixEvent[], protected room: Room) {}
constructor(protected room: Room) {}
protected getTimelineConversation = () : MatrixEvent => {
if (!this.room) return;
const cli = MatrixClientPeg.get();
const timelineSet = this.room.getUnfilteredTimelineSet();
const timelineWindow = new TimelineWindow(
cli, timelineSet,
{windowLimit: Number.MAX_VALUE});
timelineWindow.load(null, 30);
const events = timelineWindow.getEvents();
// Clone and reverse the events so that we preserve the order
arrayFastClone(events)
.reverse()
.forEach(event => {
cli.decryptEventIfNeeded(event);
});
return events;
};
abstract export(): Promise<Blob>;
}