add newline parts for text messages as well

This commit is contained in:
Bruno Windels 2019-05-14 10:37:40 +01:00
parent 3abdf6b100
commit 34dbe5f314

View file

@ -59,6 +59,17 @@ export default function parseEvent(event) {
if (content.format === "org.matrix.custom.html") {
return parseHtmlMessage(content.formatted_body);
} else {
return [new PlainPart(content.body)];
const lines = content.body.split("\n");
const parts = lines.reduce((parts, line, i) => {
const isLast = i === lines.length - 1;
const text = new PlainPart(line);
const newLine = !isLast && new NewlinePart("\n");
if (newLine) {
return parts.concat(text, newLine);
} else {
return parts.concat(text);
}
}, []);
return parts;
}
}