mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
Cache result in TextTile
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
86f4b6186a
commit
3830a95af2
@ -18,14 +18,22 @@ import {MessageTile} from "./MessageTile.js";
|
|||||||
import { MessageBodyBuilder } from "../MessageBodyBuilder.js";
|
import { MessageBodyBuilder } from "../MessageBodyBuilder.js";
|
||||||
|
|
||||||
export class TextTile extends MessageTile {
|
export class TextTile extends MessageTile {
|
||||||
get body() {
|
|
||||||
|
get _contentBody() {
|
||||||
const content = this._getContent();
|
const content = this._getContent();
|
||||||
let body = content?.body || "";
|
let body = content?.body || "";
|
||||||
if (content.msgtype === "m.emote") {
|
if (content.msgtype === "m.emote")
|
||||||
body = `* ${this.displayName} ${body}`;
|
body = `* ${this.displayName} ${body}`;
|
||||||
}
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
get body() {
|
||||||
|
const body = this._contentBody;
|
||||||
|
if (body === this._body)
|
||||||
|
return this._message;
|
||||||
const message = new MessageBodyBuilder();
|
const message = new MessageBodyBuilder();
|
||||||
message.fromText(body);
|
message.fromText(body);
|
||||||
|
[this._body, this._message] = [body, message];
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user