Construct formatted body from replied event

This commit is contained in:
aringenbach
2022-05-13 17:35:37 +02:00
parent 155847e4d5
commit 3a989a78fa
5 changed files with 166 additions and 21 deletions
@@ -155,10 +155,18 @@ extension RoomDataSource {
let editableTextMessage: NSAttributedString?
if event.isReply() {
let parser = MXReplyEventParser()
let replyEventParts = parser.parse(event)
let body: String
if let newContent = event.content[kMXMessageContentKeyNewContent] as? [String:Any] {
// Use new content if available.
body = newContent["formatted_body"] as? String ?? newContent[kMXMessageBodyKey] as? String ?? ""
} else {
// Otherwise parse MXReply.
let parser = MXReplyEventParser()
let replyEventParts = parser.parse(event)
body = replyEventParts?.formattedBodyParts?.replyText ?? replyEventParts?.bodyParts.replyText ?? ""
}
let body: String = replyEventParts?.formattedBodyParts?.replyText ?? replyEventParts?.bodyParts.replyText ?? ""
let attributed = eventFormatter.renderHTMLString(body, for: event, with: self.roomState, isEditMode: true)
if let attributed = attributed, #available(iOS 15.0, *) {
editableTextMessage = PillsFormatter.insertPills(in: attributed,