forked from shadowfacts/Tusker
Fix crash if autocomplete controller dealloc'd before search task starts
This commit is contained in:
parent
4b52cafb9a
commit
519446c5a8
|
@ -36,8 +36,8 @@ class AutocompleteEmojisController: ViewController {
|
||||||
.removeDuplicates()
|
.removeDuplicates()
|
||||||
.sink { [unowned self] query in
|
.sink { [unowned self] query in
|
||||||
self.searchTask?.cancel()
|
self.searchTask?.cancel()
|
||||||
self.searchTask = Task {
|
self.searchTask = Task { [weak self] in
|
||||||
await self.queryChanged(query)
|
await self?.queryChanged(query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ class AutocompleteHashtagsController: ViewController {
|
||||||
.debounce(for: .milliseconds(250), scheduler: DispatchQueue.main)
|
.debounce(for: .milliseconds(250), scheduler: DispatchQueue.main)
|
||||||
.sink { [unowned self] query in
|
.sink { [unowned self] query in
|
||||||
self.searchTask?.cancel()
|
self.searchTask?.cancel()
|
||||||
self.searchTask = Task {
|
self.searchTask = Task { [weak self] in
|
||||||
await self.queryChanged(query)
|
await self?.queryChanged(query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,9 @@ class AutocompleteMentionsController: ViewController {
|
||||||
.debounce(for: .milliseconds(250), scheduler: DispatchQueue.main)
|
.debounce(for: .milliseconds(250), scheduler: DispatchQueue.main)
|
||||||
.sink { [unowned self] query in
|
.sink { [unowned self] query in
|
||||||
self.searchTask?.cancel()
|
self.searchTask?.cancel()
|
||||||
self.searchTask = Task {
|
// weak in case the autocomplete controller is dealloc'd racing with the task starting
|
||||||
await self.queryChanged(query)
|
self.searchTask = Task { [weak self] in
|
||||||
|
await self?.queryChanged(query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue