From 3830a95af22bbdc2b37ffc4dc52ddb36fbaa9a6e Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 11 May 2021 16:03:14 +0530 Subject: [PATCH] Cache result in TextTile Signed-off-by: RMidhunSuresh --- src/domain/session/room/timeline/tiles/TextTile.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/domain/session/room/timeline/tiles/TextTile.js b/src/domain/session/room/timeline/tiles/TextTile.js index ba898963..34089b81 100644 --- a/src/domain/session/room/timeline/tiles/TextTile.js +++ b/src/domain/session/room/timeline/tiles/TextTile.js @@ -18,14 +18,22 @@ import {MessageTile} from "./MessageTile.js"; import { MessageBodyBuilder } from "../MessageBodyBuilder.js"; export class TextTile extends MessageTile { - get body() { + + get _contentBody() { const content = this._getContent(); let body = content?.body || ""; - if (content.msgtype === "m.emote") { + if (content.msgtype === "m.emote") body = `* ${this.displayName} ${body}`; - } + return body; + } + + get body() { + const body = this._contentBody; + if (body === this._body) + return this._message; const message = new MessageBodyBuilder(); message.fromText(body); + [this._body, this._message] = [body, message]; return message; } }