Fix changes being published during SwiftUI view update
This commit is contained in:
parent
b506704716
commit
3f4a62f5f9
|
@ -98,6 +98,7 @@ struct MainComposeWrappedTextView: UIViewRepresentable {
|
|||
if context.coordinator.skipSettingTextOnNextUpdate {
|
||||
context.coordinator.skipSettingTextOnNextUpdate = false
|
||||
} else {
|
||||
context.coordinator.skipNextAutocompleteUpdate = true
|
||||
uiView.text = text
|
||||
}
|
||||
|
||||
|
@ -185,6 +186,7 @@ struct MainComposeWrappedTextView: UIViewRepresentable {
|
|||
var caretScrollPositionAnimator: UIViewPropertyAnimator?
|
||||
|
||||
var skipSettingTextOnNextUpdate = false
|
||||
var skipNextAutocompleteUpdate = false
|
||||
|
||||
var toolbarElements: [ComposeUIState.ToolbarElement] {
|
||||
[.emojiPicker, .formattingButtons]
|
||||
|
@ -324,6 +326,10 @@ struct MainComposeWrappedTextView: UIViewRepresentable {
|
|||
}
|
||||
|
||||
private func updateAutocompleteState() {
|
||||
guard !skipNextAutocompleteUpdate else {
|
||||
skipNextAutocompleteUpdate = false
|
||||
return
|
||||
}
|
||||
guard let textView = textView,
|
||||
let text = textView.text,
|
||||
let (lastWordStartIndex, foundFirstAtSign) = findAutocompleteLastWord() else {
|
||||
|
|
Loading…
Reference in New Issue