From fa64fcce2df2d24005caa91a1f663a7c6a6056e2 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 17 May 2021 11:29:00 +0200 Subject: [PATCH] expect MessageBody here with parts property and do some cleanup --- .../session/room/timeline/TextMessageView.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/platform/web/ui/session/room/timeline/TextMessageView.js b/src/platform/web/ui/session/room/timeline/TextMessageView.js index b9eda412..4af5e5a2 100644 --- a/src/platform/web/ui/session/room/timeline/TextMessageView.js +++ b/src/platform/web/ui/session/room/timeline/TextMessageView.js @@ -16,7 +16,7 @@ limitations under the License. import {TemplateView} from "../../../general/TemplateView.js"; import {StaticView} from "../../../general/StaticView.js"; -import { tag, text } from "../../../general/html.js"; +import {tag, text} from "../../../general/html.js"; import {renderMessage} from "./common.js"; export class TextMessageView extends TemplateView { @@ -29,19 +29,19 @@ export class TextMessageView extends TemplateView { } const formatFunction = { - text: (m) => text(m.text), - link: (m) => tag.a({ href: m.url, target: "_blank", rel: "noopener" }, [text(m.text)]), + text: textPart => text(textPart.text), + link: linkPart => tag.a({ href: linkPart.url, target: "_blank", rel: "noopener" }, [linkPart.text]), newline: () => tag.br() }; class BodyView extends StaticView { - render(t, value) { - const children = []; - for (const m of value) { - const f = formatFunction[m.type]; - const element = f(m); - children.push(element); + render(t, messageBody) { + const container = t.span(); + for (const part of messageBody.parts) { + const f = formatFunction[part.type]; + const element = f(part); + container.appendChild(element); } - return t.span(children); + return container; } }