mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Adopt fuzzy searching through the RoomListService's dynamic filter
This commit is contained in:
committed by
Stefan Ceriu
parent
4503e6e0cc
commit
e13e97400b
@@ -47,6 +47,7 @@ enum HomeScreenViewAction {
|
||||
case skipSessionVerification
|
||||
case updateVisibleItemRange(range: Range<Int>, isScrolling: Bool)
|
||||
case selectInvites
|
||||
case updatedSearchQuery
|
||||
}
|
||||
|
||||
enum HomeScreenRoomListMode: CustomStringConvertible {
|
||||
@@ -84,11 +85,7 @@ struct HomeScreenViewState: BindableState {
|
||||
return placeholderRooms
|
||||
}
|
||||
|
||||
if bindings.searchQuery.isEmpty {
|
||||
return rooms
|
||||
}
|
||||
|
||||
return rooms.filter { $0.name.localizedStandardContains(bindings.searchQuery) }
|
||||
return rooms
|
||||
}
|
||||
|
||||
var bindings = HomeScreenViewStateBindings()
|
||||
|
||||
@@ -187,6 +187,8 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
callback?(.presentStartChatScreen)
|
||||
case .selectInvites:
|
||||
callback?(.presentInvitesScreen)
|
||||
case .updatedSearchQuery:
|
||||
roomSummaryProvider?.updateFilterPattern(state.bindings.searchQuery)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,9 @@ struct HomeScreen: View {
|
||||
.onReceive(scrollViewAdapter.isScrolling) { _ in
|
||||
updateVisibleRange()
|
||||
}
|
||||
.onChange(of: context.searchQuery) { searchQuery in
|
||||
guard searchQuery.isEmpty else { return }
|
||||
.onChange(of: context.searchQuery) { _ in
|
||||
context.send(viewAction: .updatedSearchQuery)
|
||||
|
||||
// Dispatch allows the view to update after changing the query
|
||||
DispatchQueue.main.async { updateVisibleRange() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user