mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Fix for extra newline in emotes (#2778)
This commit is contained in:
@@ -570,7 +570,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
|||||||
|
|
||||||
var formattedBody: AttributedString?
|
var formattedBody: AttributedString?
|
||||||
if let htmlBody {
|
if let htmlBody {
|
||||||
formattedBody = attributedStringBuilder.fromHTML(L10n.commonEmote(name, htmlBody))
|
formattedBody = buildEmoteFormattedBodyFromHTML(html: htmlBody, name: name)
|
||||||
} else {
|
} else {
|
||||||
formattedBody = attributedStringBuilder.fromPlain(L10n.commonEmote(name, messageContent.body))
|
formattedBody = attributedStringBuilder.fromPlain(L10n.commonEmote(name, messageContent.body))
|
||||||
}
|
}
|
||||||
@@ -578,6 +578,17 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
|||||||
return .init(body: messageContent.body, formattedBody: formattedBody, formattedBodyHTMLString: htmlBody)
|
return .init(body: messageContent.body, formattedBody: formattedBody, formattedBodyHTMLString: htmlBody)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This fixes the issue of the name not belonging to the first <p> 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
|
// MARK: - State Events
|
||||||
|
|
||||||
private func buildStateTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
private func buildStateTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Fixed a bug that added an extra newline between the name and a formatted text in an emote.
|
||||||
Reference in New Issue
Block a user