mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Fix for extra newline in emotes (#2778)
This commit is contained in:
parent
e9d690450e
commit
7d06b471ec
@ -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 <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
|
||||
|
||||
private func buildStateTimelineItem(for eventItemProxy: EventTimelineItemProxy,
|
||||
|
1
changelog.d/2503.bugfix
Normal file
1
changelog.d/2503.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fixed a bug that added an extra newline between the name and a formatted text in an emote.
|
Loading…
x
Reference in New Issue
Block a user