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
+2 -32
View File
@@ -1,7 +1,4 @@
import { MatrixClientPeg } from "../../MatrixClientPeg";
import { arrayFastClone } from "../arrays";
import { TimelineWindow } from "matrix-js-sdk/src/timeline-window";
import Room from 'matrix-js-sdk/src/models/room';
import { Room } from 'matrix-js-sdk/src/models/room';
import HTMLExporter from "./HtmlExport";
export enum exportFormats {
@@ -14,37 +11,10 @@ export enum exportOptions {
TIMELINE = "TIMELINE",
}
const getTimelineConversation = (room: Room) => {
if (!room) return;
const cli = MatrixClientPeg.get();
const timelineSet = 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;
};
const exportConversationalHistory = async (room: Room, format: string, options) => {
const res = getTimelineConversation(room);
switch (format) {
case exportFormats.HTML:
await new HTMLExporter(res, room).export();
await new HTMLExporter(room).export();
break;
case exportFormats.JSON:
break;