From e4a143659ce5d470bfb0aab816d4dc99c23e8d74 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 11 May 2021 14:02:25 +0530 Subject: [PATCH] Refactor unwanted getter into constant object Signed-off-by: RMidhunSuresh --- .../ui/session/room/timeline/TextMessageView.js | 17 +++++++---------- 1 file changed, 7 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 d78c49da..c07c1075 100644 --- a/src/platform/web/ui/session/room/timeline/TextMessageView.js +++ b/src/platform/web/ui/session/room/timeline/TextMessageView.js @@ -28,20 +28,17 @@ export class TextMessageView extends TemplateView { } } +const formatFunction = { + text: (param) => text(param.obj.text), + link: (param) => param.t.a({ href: param.obj.url, target: "_blank", rel: "noopener" }, [text(param.obj.text)]), + newline: (param) => param.t.br() +}; + class BodyView extends StaticView { - - get _formatFunction() { - return { - text: (param) => text(param.obj.text), - link: (param) => param.t.a({ href: param.obj.url, target: "_blank", rel: "noopener" }, [text(param.obj.text)]), - newline: (param) => param.t.br() - }; - } - render(t, value) { const children = []; for (const m of value) { - const f = this._formatFunction[m.type]; + const f = formatFunction[m.type]; const element = f({ obj: m, t: t }); children.push(element); }