Fix editing status dropping mentions / account name

This commit is contained in:
Thomas Ricouard 2023-01-15 15:02:32 +01:00
parent d05d9fbfff
commit 4fc6944360
1 changed files with 5 additions and 1 deletions

View File

@ -158,7 +158,11 @@ public class StatusEditorViewModel: ObservableObject {
self.visibility = visibility
selectedRange = .init(location: statusText.string.utf16.count, length: 0)
case let .edit(status):
statusText = .init(status.content.asMarkdown.asSafeAttributedString)
var rawText = NSAttributedString(status.content.asMarkdown.asSafeAttributedString).string
for mention in status.mentions {
rawText = rawText.replacingOccurrences(of: "@\(mention.username)", with: "@\(mention.acct)")
}
statusText = .init(string: rawText)
selectedRange = .init(location: statusText.string.utf16.count, length: 0)
spoilerOn = !status.spoilerText.isEmpty
spoilerText = status.spoilerText