Refactor
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user