From a9731f5a1db98395bde3c32c1a0808c4449e4c5e Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 4 Aug 2021 16:02:37 -0700 Subject: [PATCH] Clean up code for inserting emotes --- src/domain/session/room/timeline/MessageBody.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/domain/session/room/timeline/MessageBody.js b/src/domain/session/room/timeline/MessageBody.js index a811425c..b3cf532e 100644 --- a/src/domain/session/room/timeline/MessageBody.js +++ b/src/domain/session/room/timeline/MessageBody.js @@ -137,6 +137,10 @@ export class TextPart { get type() { return "text"; } } +function isBlockquote(part){ + return part.type === "format" && part.format === "blockquote"; +} + export class MessageBody { constructor(sourceString, parts) { this.sourceString = sourceString; @@ -148,7 +152,7 @@ export class MessageBody { // We assume that such quotes are not TextParts, because replies // must have a formatted body. let i = 0; - for (i = 0; i < this.parts.length && this.parts[i].type === "format" && this.parts[i].format === "blockquote"; i++); + for (; i < this.parts.length && isBlockquote(this.parts[i]); i++); this.parts.splice(i, 0, new TextPart(string)); } }