mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Revert "Adopt fuzzy searching through the RoomListService's dynamic filter" because of performance issues
This reverts commit e13e97400b.
This commit is contained in:
@@ -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?)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user