From 9aedc1d5267693f0743d970b59cee2db189421e4 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 16 Jul 2021 19:30:02 +0200 Subject: [PATCH] don't put body parts in span --- .../session/room/timeline/TextMessageView.js | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/platform/web/ui/session/room/timeline/TextMessageView.js b/src/platform/web/ui/session/room/timeline/TextMessageView.js index e361ac05..5988cb44 100644 --- a/src/platform/web/ui/session/room/timeline/TextMessageView.js +++ b/src/platform/web/ui/session/room/timeline/TextMessageView.js @@ -14,21 +14,28 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {StaticView} from "../../../general/StaticView.js"; import {tag, text, classNames} from "../../../general/html.js"; import {BaseMessageView} from "./BaseMessageView.js"; export class TextMessageView extends BaseMessageView { renderMessageBody(t, vm) { - return t.p({ + const time = t.time({className: {hidden: !vm.date}}, vm.date + " " + vm.time); + const container = t.div({ className: { "Timeline_messageBody": true, statusMessage: vm => vm.shape === "message-status", }, - }, [ - t.mapView(vm => vm.body, body => new BodyView(body)), - t.time({className: {hidden: !vm.date}}, vm.date + " " + vm.time) - ]); + }); + t.mapSideEffect(vm => vm.body, body => { + while (container.lastChild) { + container.removeChild(container.lastChild); + } + for (const part of body.parts) { + container.appendChild(renderPart(part)); + } + container.appendChild(time); + }); + return container; } } @@ -105,13 +112,3 @@ function renderPart(part) { function renderParts(parts) { return Array.from(parts, renderPart); } - -class BodyView extends StaticView { - render(t, messageBody) { - const container = t.span(); - for (const part of messageBody.parts) { - container.appendChild(renderPart(part)); - } - return container; - } -}