diff --git a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift index 43dcf36f7..5b6d2fd27 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift @@ -570,7 +570,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol { var formattedBody: AttributedString? if let htmlBody { - formattedBody = attributedStringBuilder.fromHTML(L10n.commonEmote(name, htmlBody)) + formattedBody = buildEmoteFormattedBodyFromHTML(html: htmlBody, name: name) } else { formattedBody = attributedStringBuilder.fromPlain(L10n.commonEmote(name, messageContent.body)) } @@ -578,6 +578,17 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol { return .init(body: messageContent.body, formattedBody: formattedBody, formattedBodyHTMLString: htmlBody) } + // This fixes the issue of the name not belonging to the first

defined paragraph + private func buildEmoteFormattedBodyFromHTML(html: String, name: String) -> AttributedString? { + let htmlBodyPlaceholder = "{htmlBodyPlaceholder}" + var finalString = AttributedString(L10n.commonEmote(name, htmlBodyPlaceholder)) + guard let htmlBodyString = attributedStringBuilder.fromHTML(html) else { + return nil + } + finalString.replace(htmlBodyPlaceholder, with: htmlBodyString) + return finalString + } + // MARK: - State Events private func buildStateTimelineItem(for eventItemProxy: EventTimelineItemProxy, diff --git a/changelog.d/2503.bugfix b/changelog.d/2503.bugfix new file mode 100644 index 000000000..aad6a6b2c --- /dev/null +++ b/changelog.d/2503.bugfix @@ -0,0 +1 @@ +Fixed a bug that added an extra newline between the name and a formatted text in an emote. \ No newline at end of file