Add check for body

This commit is contained in:
Florian Duros 2022-10-26 19:09:12 +02:00
parent 3d1a0ccf12
commit c0282e0351
No known key found for this signature in database
GPG key ID: 9700AA5870258A0B

View file

@ -60,6 +60,9 @@ function getHtmlReplyFallback(mxEvent: MatrixEvent): string {
function getTextReplyFallback(mxEvent: MatrixEvent): string { function getTextReplyFallback(mxEvent: MatrixEvent): string {
const body = mxEvent.getContent().body; const body = mxEvent.getContent().body;
if (!body) {
return "";
}
const lines = body.split("\n").map(l => l.trim()); const lines = body.split("\n").map(l => l.trim());
if (lines.length > 2 && lines[0].startsWith("> ") && lines[1].length === 0) { if (lines.length > 2 && lines[0].startsWith("> ") && lines[1].length === 0) {
return `${lines[0]}\n\n`; return `${lines[0]}\n\n`;