Strip in reply to from thread summary and from the latest message

This commit is contained in:
ismailgulek
2022-03-18 18:04:21 +03:00
parent 2457774ac7
commit 78e77e610a
3 changed files with 23 additions and 20 deletions
@@ -206,25 +206,8 @@ 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,
return eventFormatter.attributedString(from: message.replyStrippedVersion,
with: roomState,
error: formatterError)
}
@@ -238,7 +221,7 @@ final class ThreadListViewModel: ThreadListViewModelProtocol {
}
let formatterError = UnsafeMutablePointer<MXKEventFormatterError>.allocate(capacity: 1)
return (
eventFormatter.attributedString(from: message,
eventFormatter.attributedString(from: message.replyStrippedVersion,
with: roomState,
error: formatterError),
eventFormatter.dateString(from: message, withTime: true)