diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index d6b4822cc2..ed2ca07ff5 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -32,7 +32,8 @@ import RoomTopic from "../elements/RoomTopic"; import RoomName from "../elements/RoomName"; import {PlaceCallType} from "../../../CallHandler"; import {replaceableComponent} from "../../../utils/replaceableComponent"; -import exportConversationalHistory from '../../../utils/exportUtils'; +import exportConversationalHistory from '../../../utils/exportUtils/exportUtils'; +import { exportFormats, exportOptions } from '../../../utils/exportUtils/exportUtils'; @replaceableComponent("views.rooms.RoomHeader") @@ -120,7 +121,7 @@ export default class RoomHeader extends React.Component { } _exportConvertionalHistory = async () => { - exportConversationalHistory(this.props.room); + exportConversationalHistory(this.props.room, exportFormats.HTML, exportOptions.TIMELINE); } render() { diff --git a/src/utils/exportUtils.js b/src/utils/exportUtils/HtmlExport.ts similarity index 80% rename from src/utils/exportUtils.js rename to src/utils/exportUtils/HtmlExport.ts index 0ab65df911..1b0d59ab6b 100644 --- a/src/utils/exportUtils.js +++ b/src/utils/exportUtils/HtmlExport.ts @@ -1,13 +1,13 @@ -import { MatrixClientPeg } from "../MatrixClientPeg"; -import { arrayFastClone } from "./arrays"; -import { TimelineWindow } from "matrix-js-sdk/src/timeline-window"; -import JSZip from "jszip"; -import { textForEvent } from "../TextForEvent"; -import streamSaver from "streamsaver"; -import { decryptFile } from "./DecryptFile"; -import { mediaFromContent, mediaFromMxc } from "../customisations/Media"; -const wrapHTML = (content, room) => (` +import streamSaver from "streamsaver"; +import JSZip from "jszip"; +import { decryptFile } from "../DecryptFile"; +import { mediaFromContent, mediaFromMxc } from "../../customisations/Media"; +import { textForEvent } from "../../TextForEvent"; +import Room from 'matrix-js-sdk/src/models/room'; +import { MatrixEvent } from "matrix-js-sdk/src/models/event"; + +const wrapHTML = (content: string, room: Room) => (`
@@ -270,59 +270,27 @@ div.selected { `; -const getTimelineConversation = (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); - }); - - if (!timelineWindow.canPaginate('f')) { - events.push(...timelineSet.getPendingEvents()); - } - console.log(events); - return events; -}; - - const userColors = [ "#64bf47", "#4f9cd9", "#9884e8", - "#e671a5", - "#47bcd1", - "#ff8c44", ]; - //Get a color associated with string length. This is to map userId to a specific color -const getUserColor = (userId) => { +const getUserColor = (userId: string) => { return userColors[userId.length % 4]; }; -const getUserPic = async (event) => { +const getUserPic = async (event: MatrixEvent) => { const member = event.sender; if (!member.getMxcAvatarUrl()) { return `