Fix room list search bar focus glitches (#2112)

* Fixes #2112 - Room list search bar focus glitches

* Address PR comments
This commit is contained in:
Stefan Ceriu
2023-11-17 18:08:29 +02:00
committed by GitHub
parent d245a4f158
commit f717c7dba4
4 changed files with 24 additions and 6 deletions
@@ -109,7 +109,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
// Don't capture the values here as combine behaves incorrectly and `isSearchFieldFocused` is sometimes
// turning to true after cancelling the search. Read them directly from the state in the updateFilter
// method instead on the next run loop to make sure they're up to date.
DispatchQueue.main.async {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
self.updateFilter()
}
}
@@ -170,12 +170,14 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
// MARK: - Private
private func updateFilter() {
if !state.bindings.isSearchFieldFocused {
roomSummaryProvider?.setFilter(.all)
} else if state.bindings.searchQuery.isEmpty {
if state.shouldHideRoomList {
roomSummaryProvider?.setFilter(.none)
} else {
roomSummaryProvider?.setFilter(.normalizedMatchRoomName(state.bindings.searchQuery))
if state.bindings.isSearchFieldFocused {
roomSummaryProvider?.setFilter(.normalizedMatchRoomName(state.bindings.searchQuery))
} else {
roomSummaryProvider?.setFilter(.all)
}
}
}