mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Fix event content where the thread root event is a reply event
This commit is contained in:
parent
d5de3a9b2f
commit
d7ed2d3b09
2 changed files with 18 additions and 1 deletions
|
@ -204,6 +204,23 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
|
|||
guard let message = thread.rootMessage else {
|
||||
return nil
|
||||
}
|
||||
if message.isReply(), let newMessage = message.copy() as? MXEvent {
|
||||
var jsonDict = newMessage.isEncrypted ? newMessage.clear?.jsonDictionary() : newMessage.jsonDictionary()
|
||||
if var content = jsonDict?["content"] as? [String: Any] {
|
||||
content.removeValue(forKey: "format")
|
||||
content.removeValue(forKey: "formatted_body")
|
||||
content.removeValue(forKey: kMXEventRelationRelatesToKey)
|
||||
if let replyText = MXReplyEventParser().parse(newMessage)?.bodyParts.replyText {
|
||||
content["body"] = replyText
|
||||
}
|
||||
jsonDict?["content"] = content
|
||||
}
|
||||
let trimmedMessage = MXEvent(fromJSON: jsonDict)
|
||||
let formatterError = UnsafeMutablePointer<MXKEventFormatterError>.allocate(capacity: 1)
|
||||
return eventFormatter.attributedString(from: trimmedMessage,
|
||||
with: roomState,
|
||||
error: formatterError)
|
||||
}
|
||||
let formatterError = UnsafeMutablePointer<MXKEventFormatterError>.allocate(capacity: 1)
|
||||
return eventFormatter.attributedString(from: message,
|
||||
with: roomState,
|
||||
|
|
|
@ -427,7 +427,7 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
if event.isReply() {
|
||||
let parser = MXReplyEventParser()
|
||||
let replyParts = parser.parse(event)
|
||||
notificationBody = replyParts.bodyParts.replyText
|
||||
notificationBody = replyParts?.bodyParts.replyText
|
||||
} else {
|
||||
notificationBody = messageContent
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue