Fuzzy searching debouncing (#1506)

* Add debouncer to room list fuzzy searching

* Fix function_body_length violation

* Filter out search query changes if fuzzy searching is not enabled
This commit is contained in:
Stefan Ceriu
2023-08-17 15:35:59 +03:00
committed by GitHub
parent 22e4f21b99
commit a11325bcb4
3 changed files with 65 additions and 60 deletions
@@ -79,14 +79,9 @@ struct HomeScreen: View {
.onReceive(scrollViewAdapter.isScrolling) { _ in
updateVisibleRange()
}
.onChange(of: context.searchQuery) { searchQuery in
if context.viewState.fuzzySearchEnabled {
context.send(viewAction: .updatedSearchQuery)
} else {
guard searchQuery.isEmpty else { return }
// Dispatch allows the view to update after changing the query
DispatchQueue.main.async { updateVisibleRange() }
}
.onChange(of: context.searchQuery) { _ in
// Dispatch allows the view to update after changing the query
DispatchQueue.main.async { updateVisibleRange() }
}
.onReceive(scrollViewAdapter.scrollDirection) { direction in
withAnimation(.elementDefault) { lastScrollDirection = direction }