Handle export cancellation

This commit is contained in:
Jaiwanth 2021-06-27 20:55:54 +05:30
parent 398d49245f
commit d46fe678b0
6 changed files with 107 additions and 54 deletions

View file

@ -64,6 +64,7 @@ ${json}
protected async createOutput(events: MatrixEvent[]) {
let content = "";
for (const event of events) {
if (this.cancelled) return this.cleanUp();
if (!haveTileForEvent(event)) continue;
content += await this.getJSONString(event);
}
@ -93,11 +94,14 @@ ${json}
const exportEnd = performance.now();
console.info("Export successful!")
console.log(`Exported ${res.length} events in ${(exportEnd - fetchStart)/1000} seconds`);
if (this.cancelled) {
console.info("Export cancelled successfully");
} else {
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);
this.cleanUp()
}
}