From 4af8ec4d408900c1464c526819b83343df781e28 Mon Sep 17 00:00:00 2001 From: Jaiwanth Date: Fri, 25 Jun 2021 15:19:17 +0530 Subject: [PATCH] Explicitly declare file extensions for stickers and log event fetching progress --- src/utils/exportUtils/Exporter.ts | 5 +++-- src/utils/exportUtils/HtmlExport.tsx | 2 +- src/utils/exportUtils/JSONExport.ts | 7 ++++--- src/utils/exportUtils/PlainTextExport.ts | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index 832d990f61..0834cb7dc8 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -148,7 +148,7 @@ export default abstract class Exporter { } events.push(mxEv); } - + console.log("Fetched " + events.length + " events so far."); prevToken = res.end; } // Reverse the events so that we preserve the order @@ -216,7 +216,8 @@ export default abstract class Exporter { fileDirectory = event.getType() === "m.sticker" ? "stickers" : "files"; } const fileDate = formatFullDateNoDay(new Date(event.getTs())); - const [fileName, fileExt] = this.splitFileName(event.getContent().body); + let [fileName, fileExt] = this.splitFileName(event.getContent().body); + if (event.getType() === "m.sticker") fileExt = ".png"; return fileDirectory + "/" + fileName + '-' + fileDate + fileExt; } diff --git a/src/utils/exportUtils/HtmlExport.tsx b/src/utils/exportUtils/HtmlExport.tsx index 6415f996db..7b36439ad5 100644 --- a/src/utils/exportUtils/HtmlExport.tsx +++ b/src/utils/exportUtils/HtmlExport.tsx @@ -328,7 +328,7 @@ export default class HTMLExporter extends Exporter { const res = await this.getRequiredEvents(); const fetchEnd = performance.now(); - console.log(`Fetched ${res.length} events in ${(fetchEnd - fetchStart)/1000} s`); + console.log(`Fetched ${res.length} events in ${(fetchEnd - fetchStart)/1000}s`); console.info("Creating HTML..."); const html = await this.createHTML(res); diff --git a/src/utils/exportUtils/JSONExport.ts b/src/utils/exportUtils/JSONExport.ts index b261b305f9..4612a37481 100644 --- a/src/utils/exportUtils/JSONExport.ts +++ b/src/utils/exportUtils/JSONExport.ts @@ -77,8 +77,8 @@ ${json} const res = await this.getRequiredEvents(); const fetchEnd = performance.now(); - console.log(`Fetched ${res.length} events in ${(fetchEnd - fetchStart)/1000} s`); - console.info("Creating Output..."); + console.log(`Fetched ${res.length} events in ${(fetchEnd - fetchStart)/1000}s`); + console.info("Creating output..."); const text = await this.createOutput(res); @@ -91,7 +91,8 @@ ${json} } const exportEnd = performance.now(); - console.info(`Export Successful! Exported ${res.length} events in ${(exportEnd - fetchStart)/1000} seconds`); + console.info(`Export successful!`) + console.log(`Exported ${res.length} events in ${(exportEnd - fetchStart)/1000} seconds`); window.removeEventListener("beforeunload", this.onBeforeUnload); window.removeEventListener("onunload", this.abortExport); } diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index 4ec2e81d9d..f8bb6fe34e 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -95,7 +95,7 @@ export default class PlainTextExporter extends Exporter { const res = await this.getRequiredEvents(); const fetchEnd = performance.now(); - console.log(`Fetched ${res.length} events in ${(fetchEnd - fetchStart)/1000} s`); + console.log(`Fetched ${res.length} events in ${(fetchEnd - fetchStart)/1000}s`); console.info("Creating Output..."); const text = await this.createOutput(res);