${event.sender.name[0]}
@@ -369,7 +373,7 @@ const createMessageBody = async (event: MatrixEvent, joined = false, isReply = f
${new Date(event.getTs()).toLocaleTimeString().slice(0, -3)}
+
${event.sender.name}
`: ``}
${isReply ?
@@ -414,7 +418,7 @@ const createHTML = async (events: MatrixEvent[], room: Room) => {
};
const avatars = new Map();
-let zip: any;
+let zip: JSZip;
const exportAsHTML = async (res: MatrixEvent[], room: Room) => {
zip = new JSZip();
@@ -432,7 +436,7 @@ const exportAsHTML = async (res: MatrixEvent[], room: Room) => {
const blob = await zip.generateAsync({ type: "blob" });
//Create a writable stream to the directory
- const fileStream = streamSaver.createWriteStream(filename, blob.size);
+ const fileStream = streamSaver.createWriteStream(filename, { size: blob.size });
const writer = fileStream.getWriter();
// Here we chunk the blob into pieces of 10 MB, the size might be dynamically generated.
diff --git a/src/utils/exportUtils/exportUtils.js b/src/utils/exportUtils/exportUtils.ts
similarity index 76%
rename from src/utils/exportUtils/exportUtils.js
rename to src/utils/exportUtils/exportUtils.ts
index c73fd90a5a..b5356ca1e5 100644
--- a/src/utils/exportUtils/exportUtils.js
+++ b/src/utils/exportUtils/exportUtils.ts
@@ -1,19 +1,20 @@
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 exportAsHTML from "./HtmlExport";
-export const exportFormats = Object.freeze({
- "HTML": "HTML",
- "JSON": "JSON",
- "LOGS": "LOGS",
-});
+export enum exportFormats {
+ HTML = "HTML",
+ JSON = "JSON",
+ LOGS = "LOGS",
+}
-export const exportOptions = Object.freeze({
- "TIMELINE": "TIMELINE",
-});
+export enum exportOptions {
+ TIMELINE = "TIMELINE",
+}
-const getTimelineConversation = (room) => {
+const getTimelineConversation = (room: Room) => {
if (!room) return;
const cli = MatrixClientPeg.get();
@@ -35,12 +36,11 @@ const getTimelineConversation = (room) => {
cli.decryptEventIfNeeded(event);
});
- console.log(events);
return events;
};
-const exportConversationalHistory = async (room, format, options) => {
+const exportConversationalHistory = async (room: Room, format: string, options) => {
const res = getTimelineConversation(room);
switch (format) {
case exportFormats.HTML:
diff --git a/yarn.lock b/yarn.lock
index 438cc94f27..982b9e607b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1655,6 +1655,11 @@
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.0.tgz#7036640b4e21cc2f259ae826ce843d277dad8cff"
integrity sha512-RJJrrySY7A8havqpGObOB4W92QXKJo63/jFLLgpvOtsGUqbQZ9Sbgl35KMm1DjC6j7AvmmU2bIno+3IyEaemaw==
+"@types/streamsaver@^2.0.0":
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/@types/streamsaver/-/streamsaver-2.0.0.tgz#2a6bdec0389f41a74c60091d37e84f8840d27ac9"
+ integrity sha512-TzUEZk30QmNaS6GAhcOnH/Cl2mO7HCFhQUr6GpzvuoFziFCxmvuyLftHW79agJpZvIrqti9jSiDHMgflUwbejg==
+
"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e"