Add braces to all blocks

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-05-11 17:59:03 +05:30
parent 3830a95af2
commit dbe76e973e
2 changed files with 17 additions and 8 deletions

View file

@ -9,25 +9,32 @@ export class MessageBodyBuilder {
fromText(text) { fromText(text) {
const components = text.split("\n"); const components = text.split("\n");
components.flatMap(e => ["\n", e]).slice(1).forEach(e => { components.flatMap(e => ["\n", e]).slice(1).forEach(e => {
if (e === "\n") if (e === "\n") {
this.insertNewline(); this.insertNewline();
else }
else {
linkify(e, this.insert.bind(this)); linkify(e, this.insert.bind(this));
}
}); });
} }
insert(text, isLink) { insert(text, isLink) {
if (!text.length) return; if (!text.length) {
if (isLink) return;
}
if (isLink) {
this.insertLink(text, text); this.insertLink(text, text);
else }
else {
this.insertText(text); this.insertText(text);
} }
}
insertText(text) { insertText(text) {
if (text.length) if (text.length) {
this._root.push({ type: "text", text: text }); this._root.push({ type: "text", text: text });
} }
}
insertLink(link, displayText) { insertLink(link, displayText) {
this._root.push({ type: "link", url: link, text: displayText }); this._root.push({ type: "link", url: link, text: displayText });

View file

@ -22,15 +22,17 @@ export class TextTile extends MessageTile {
get _contentBody() { 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; return body;
} }
get body() { get body() {
const body = this._contentBody; const body = this._contentBody;
if (body === this._body) if (body === this._body) {
return this._message; return this._message;
}
const message = new MessageBodyBuilder(); const message = new MessageBodyBuilder();
message.fromText(body); message.fromText(body);
[this._body, this._message] = [body, message]; [this._body, this._message] = [body, message];