forked from shadowfacts/Tusker
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 {
|
if context.coordinator.skipSettingTextOnNextUpdate {
|
||||||
context.coordinator.skipSettingTextOnNextUpdate = false
|
context.coordinator.skipSettingTextOnNextUpdate = false
|
||||||
} else {
|
} else {
|
||||||
|
context.coordinator.skipNextAutocompleteUpdate = true
|
||||||
uiView.text = text
|
uiView.text = text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,6 +186,7 @@ struct MainComposeWrappedTextView: UIViewRepresentable {
|
||||||
var caretScrollPositionAnimator: UIViewPropertyAnimator?
|
var caretScrollPositionAnimator: UIViewPropertyAnimator?
|
||||||
|
|
||||||
var skipSettingTextOnNextUpdate = false
|
var skipSettingTextOnNextUpdate = false
|
||||||
|
var skipNextAutocompleteUpdate = false
|
||||||
|
|
||||||
var toolbarElements: [ComposeUIState.ToolbarElement] {
|
var toolbarElements: [ComposeUIState.ToolbarElement] {
|
||||||
[.emojiPicker, .formattingButtons]
|
[.emojiPicker, .formattingButtons]
|
||||||
|
@ -324,6 +326,10 @@ struct MainComposeWrappedTextView: UIViewRepresentable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateAutocompleteState() {
|
private func updateAutocompleteState() {
|
||||||
|
guard !skipNextAutocompleteUpdate else {
|
||||||
|
skipNextAutocompleteUpdate = false
|
||||||
|
return
|
||||||
|
}
|
||||||
guard let textView = textView,
|
guard let textView = textView,
|
||||||
let text = textView.text,
|
let text = textView.text,
|
||||||
let (lastWordStartIndex, foundFirstAtSign) = findAutocompleteLastWord() else {
|
let (lastWordStartIndex, foundFirstAtSign) = findAutocompleteLastWord() else {
|
||||||
|
|
Loading…
Reference in New Issue