Revert "Adopt fuzzy searching through the RoomListService's dynamic filter" because of performance issues
This reverts commit fcca9be20f.
This commit is contained in:
@@ -47,7 +47,6 @@ enum HomeScreenViewAction {
|
||||
case skipSessionVerification
|
||||
case updateVisibleItemRange(range: Range<Int>, isScrolling: Bool)
|
||||
case selectInvites
|
||||
case updatedSearchQuery
|
||||
}
|
||||
|
||||
enum HomeScreenRoomListMode: CustomStringConvertible {
|
||||
@@ -85,7 +84,11 @@ struct HomeScreenViewState: BindableState {
|
||||
return placeholderRooms
|
||||
}
|
||||
|
||||
return rooms
|
||||
if bindings.searchQuery.isEmpty {
|
||||
return rooms
|
||||
}
|
||||
|
||||
return rooms.filter { $0.name.localizedStandardContains(bindings.searchQuery) }
|
||||
}
|
||||
|
||||
var bindings = HomeScreenViewStateBindings()
|
||||
|
||||
@@ -187,8 +187,6 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
callback?(.presentStartChatScreen)
|
||||
case .selectInvites:
|
||||
callback?(.presentInvitesScreen)
|
||||
case .updatedSearchQuery:
|
||||
roomSummaryProvider?.updateFilterPattern(state.bindings.searchQuery)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,9 +79,8 @@ struct HomeScreen: View {
|
||||
.onReceive(scrollViewAdapter.isScrolling) { _ in
|
||||
updateVisibleRange()
|
||||
}
|
||||
.onChange(of: context.searchQuery) { _ in
|
||||
context.send(viewAction: .updatedSearchQuery)
|
||||
|
||||
.onChange(of: context.searchQuery) { searchQuery in
|
||||
guard searchQuery.isEmpty else { return }
|
||||
// Dispatch allows the view to update after changing the query
|
||||
DispatchQueue.main.async { updateVisibleRange() }
|
||||
}
|
||||
|
||||
@@ -45,8 +45,6 @@ class MockRoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
func setRoomList(_ roomList: RoomList) { }
|
||||
|
||||
func updateVisibleRange(_ range: Range<Int>) { }
|
||||
|
||||
func updateFilterPattern(_ pattern: String?) { }
|
||||
}
|
||||
|
||||
extension Array where Element == RoomSummary {
|
||||
|
||||
@@ -28,7 +28,6 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
private var roomList: RoomListProtocol?
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
private var listUpdatesSubscriptionResult: RoomListEntriesWithDynamicFilterResult?
|
||||
private var listUpdatesTaskHandle: TaskHandle?
|
||||
private var stateUpdatesTaskHandle: TaskHandle?
|
||||
|
||||
@@ -74,17 +73,21 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
self.roomList = roomList
|
||||
|
||||
do {
|
||||
listUpdatesSubscriptionResult = roomList.entriesWithDynamicFilter(listener: RoomListEntriesListenerProxy { [weak self] updates in
|
||||
let listUpdatesSubscriptionResult = roomList.entries(listener: RoomListEntriesListenerProxy { [weak self] updates in
|
||||
guard let self else { return }
|
||||
MXLog.info("\(name): Received list update")
|
||||
diffsPublisher.send(updates)
|
||||
})
|
||||
|
||||
listUpdatesTaskHandle = listUpdatesSubscriptionResult?.entriesStream
|
||||
|
||||
// Forces the listener above to be called with the current state
|
||||
updateFilterPattern(nil)
|
||||
|
||||
listUpdatesTaskHandle = listUpdatesSubscriptionResult.entriesStream
|
||||
|
||||
rooms = listUpdatesSubscriptionResult.entries.map { roomListEntry in
|
||||
buildSummaryForRoomListEntry(roomListEntry)
|
||||
}
|
||||
|
||||
// Manually call it here as the didSet doesn't work from constructors
|
||||
roomListSubject.send(rooms)
|
||||
|
||||
let stateUpdatesSubscriptionResult = try roomList.loadingState(listener: RoomListStateObserver { [weak self] state in
|
||||
guard let self else { return }
|
||||
MXLog.info("\(name): Received state update: \(state)")
|
||||
@@ -110,15 +113,6 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func updateFilterPattern(_ pattern: String?) {
|
||||
guard let pattern, !pattern.isEmpty else {
|
||||
_ = listUpdatesSubscriptionResult?.dynamicFilter.set(kind: .all)
|
||||
return
|
||||
}
|
||||
|
||||
_ = listUpdatesSubscriptionResult?.dynamicFilter.set(kind: .fuzzyMatchRoomName(pattern: pattern.lowercased()))
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
fileprivate func updateRoomsWithDiffs(_ diffs: [RoomListEntriesUpdate]) {
|
||||
|
||||
@@ -99,6 +99,4 @@ protocol RoomSummaryProviderProtocol {
|
||||
func setRoomList(_ roomList: RoomList)
|
||||
|
||||
func updateVisibleRange(_ range: Range<Int>)
|
||||
|
||||
func updateFilterPattern(_ pattern: String?)
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Allow fuzzy searching for room list rooms
|
||||
Reference in New Issue
Block a user