diff --git a/Riot/Modules/MatrixKit/Categories/NSAttributedString+MatrixKit.swift b/Riot/Modules/MatrixKit/Categories/NSAttributedString+MatrixKit.swift index c72e5c76c..afee51868 100644 --- a/Riot/Modules/MatrixKit/Categories/NSAttributedString+MatrixKit.swift +++ b/Riot/Modules/MatrixKit/Categories/NSAttributedString+MatrixKit.swift @@ -29,4 +29,11 @@ public extension NSAttributedString { return unquotedSubstrings.joined(separator: " ") as NSString } + + /// Returns a new attributed string by removing all links from the receiver. + @objc var byRemovingLinks: NSAttributedString { + let result = NSMutableAttributedString(attributedString: self) + result.removeAttribute(.link, range: NSRange(location: 0, length: length)) + return result + } } diff --git a/Riot/Modules/Threads/ThreadList/ThreadListViewModel.swift b/Riot/Modules/Threads/ThreadList/ThreadListViewModel.swift index af2459446..1f2dd01f5 100644 --- a/Riot/Modules/Threads/ThreadList/ThreadListViewModel.swift +++ b/Riot/Modules/Threads/ThreadList/ThreadListViewModel.swift @@ -209,7 +209,7 @@ final class ThreadListViewModel: ThreadListViewModelProtocol { let formatterError = UnsafeMutablePointer.allocate(capacity: 1) return eventFormatter.attributedString(from: message.replyStrippedVersion, with: roomState, - error: formatterError) + error: formatterError).byRemovingLinks } private func lastMessageTextAndTime(forThread thread: MXThreadProtocol) -> (NSAttributedString?, String?) {