mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-14 08:03:10 +03:00
try catch for plain text
This commit is contained in:
parent
02f15d573a
commit
abbe047bfd
2 changed files with 19 additions and 10 deletions
|
@ -118,7 +118,7 @@ export default abstract class Exporter {
|
||||||
limit = 40;
|
limit = 40;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
limit = Number.MAX_VALUE;
|
limit = 10**8;
|
||||||
}
|
}
|
||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,16 +56,25 @@ export default class PlainTextExporter extends Exporter {
|
||||||
|
|
||||||
protected _textForEvent = async (mxEv: MatrixEvent) => {
|
protected _textForEvent = async (mxEv: MatrixEvent) => {
|
||||||
const senderDisplayName = mxEv.sender && mxEv.sender.name ? mxEv.sender.name : mxEv.getSender();
|
const senderDisplayName = mxEv.sender && mxEv.sender.name ? mxEv.sender.name : mxEv.getSender();
|
||||||
if (this.exportOptions.attachmentsIncluded && this.isAttachment(mxEv)) {
|
let mediaText = "";
|
||||||
|
if (this.isAttachment(mxEv)) {
|
||||||
|
if (this.exportOptions.attachmentsIncluded) {
|
||||||
|
try {
|
||||||
const blob = await this.getMediaBlob(mxEv);
|
const blob = await this.getMediaBlob(mxEv);
|
||||||
this.totalSize += blob.size;
|
this.totalSize += blob.size;
|
||||||
const filePath = this.getFilePath(mxEv);
|
const filePath = this.getFilePath(mxEv);
|
||||||
|
mediaText = " (" + _t("File Attached") + ")";
|
||||||
this.addFile(filePath, blob);
|
this.addFile(filePath, blob);
|
||||||
if (this.totalSize > this.exportOptions.maxSize - 1024 * 1024) {
|
if (this.totalSize > this.exportOptions.maxSize - 1024 * 1024) {
|
||||||
this.exportOptions.attachmentsIncluded = false;
|
this.exportOptions.attachmentsIncluded = false;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
mediaText = " (" + _t("Error fetching file") + ")";
|
||||||
|
console.log("Error fetching file" + error);
|
||||||
}
|
}
|
||||||
if (this.isReply(mxEv)) return senderDisplayName + ": " + this.textForReplyEvent(mxEv);
|
} else mediaText = ` (${this.mediaOmitText})`;
|
||||||
|
}
|
||||||
|
if (this.isReply(mxEv)) return senderDisplayName + ": " + this.textForReplyEvent(mxEv) + mediaText;
|
||||||
else return textForEvent(mxEv);
|
else return textForEvent(mxEv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue