Refactor
This commit is contained in:
parent
183166c460
commit
4c22d1f2a1
3 changed files with 55 additions and 52 deletions
|
@ -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>;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue