Compare commits

..

2 Commits

3 changed files with 13 additions and 9 deletions

View File

@ -29,6 +29,12 @@ class Draft: Codable, ObservableObject {
attachments.count > 0 attachments.count > 0
} }
var textForPosting: String {
// when using dictation, iOS sometimes leaves a U+FFFC OBJECT REPLACEMENT CHARACTER behind in the text,
// which we want to strip out before actually posting the status
text.replacingOccurrences(of: "\u{fffc}", with: "")
}
init(accountID: String) { init(accountID: String) {
self.id = UUID() self.id = UUID()
self.lastModified = Date() self.lastModified = Date()

View File

@ -197,7 +197,7 @@ struct ComposeView: View {
self.isPosting = false self.isPosting = false
case let .success(uploadedAttachments): case let .success(uploadedAttachments):
let request = Client.createStatus(text: draft.text, let request = Client.createStatus(text: draft.textForPosting,
contentType: Preferences.shared.statusContentType, contentType: Preferences.shared.statusContentType,
inReplyTo: draft.inReplyToID, inReplyTo: draft.inReplyToID,
media: uploadedAttachments, media: uploadedAttachments,

View File

@ -149,20 +149,18 @@ struct MainComposeWrappedTextView: UIViewRepresentable {
context.coordinator.didChange = textDidChange context.coordinator.didChange = textDidChange
context.coordinator.uiState = uiState context.coordinator.uiState = uiState
if becomeFirstResponder { // wait until the next runloop iteration so that SwiftUI view updates have finished and
DispatchQueue.main.async { // the text view knows its new content size
DispatchQueue.main.async {
self.textDidChange(uiView)
if becomeFirstResponder {
// calling becomeFirstResponder during the SwiftUI update causes a crash on iOS 13 // calling becomeFirstResponder during the SwiftUI update causes a crash on iOS 13
uiView.becomeFirstResponder() uiView.becomeFirstResponder()
// can't update @State vars during the SwiftUI update // can't update @State vars during the SwiftUI update
becomeFirstResponder = false becomeFirstResponder = false
} }
} }
// wait until the next runloop iteration so that SwiftUI view updates have finished and
// the text view knows its new content size
DispatchQueue.main.async {
self.textDidChange(uiView)
}
} }
func makeCoordinator() -> Coordinator { func makeCoordinator() -> Coordinator {