Refactor unwanted getter into constant object
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
051771397c
commit
e4a143659c
1 changed files with 7 additions and 10 deletions
|
@ -28,20 +28,17 @@ export class TextMessageView extends TemplateView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BodyView extends StaticView {
|
const formatFunction = {
|
||||||
|
|
||||||
get _formatFunction() {
|
|
||||||
return {
|
|
||||||
text: (param) => text(param.obj.text),
|
text: (param) => text(param.obj.text),
|
||||||
link: (param) => param.t.a({ href: param.obj.url, target: "_blank", rel: "noopener" }, [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()
|
newline: (param) => param.t.br()
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
class BodyView extends StaticView {
|
||||||
render(t, value) {
|
render(t, value) {
|
||||||
const children = [];
|
const children = [];
|
||||||
for (const m of value) {
|
for (const m of value) {
|
||||||
const f = this._formatFunction[m.type];
|
const f = formatFunction[m.type];
|
||||||
const element = f({ obj: m, t: t });
|
const element = f({ obj: m, t: t });
|
||||||
children.push(element);
|
children.push(element);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue