Add a feature flag for fuzzy room list searching

This commit is contained in:
Stefan Ceriu
2024-06-17 12:57:27 +03:00
committed by Stefan Ceriu
parent 5f9310e943
commit b614f43d00
6 changed files with 28 additions and 6 deletions
@@ -24,6 +24,7 @@ import MatrixRustSDK
class ClientProxy: ClientProxyProtocol {
private let client: ClientProtocol
private let networkMonitor: NetworkMonitorProtocol
private let appSettings: AppSettings
private let mediaLoader: MediaLoaderProtocol
private let clientQueue: DispatchQueue
@@ -123,9 +124,11 @@ class ClientProxy: ClientProxyProtocol {
private let sendQueueStatusSubject = CurrentValueSubject<Bool, Never>(false)
init(client: ClientProtocol,
networkMonitor: NetworkMonitorProtocol) async {
networkMonitor: NetworkMonitorProtocol,
appSettings: AppSettings) async {
self.client = client
self.networkMonitor = networkMonitor
self.appSettings = appSettings
clientQueue = .init(label: "ClientProxyQueue", attributes: .concurrent)
@@ -726,13 +729,15 @@ class ClientProxy: ClientProxyProtocol {
eventStringBuilder: eventStringBuilder,
name: "AllRooms",
shouldUpdateVisibleRange: true,
notificationSettings: notificationSettings)
notificationSettings: notificationSettings,
appSettings: appSettings)
try await roomSummaryProvider?.setRoomList(roomListService.allRooms())
alternateRoomSummaryProvider = RoomSummaryProvider(roomListService: roomListService,
eventStringBuilder: eventStringBuilder,
name: "MessageForwarding",
notificationSettings: notificationSettings)
notificationSettings: notificationSettings,
appSettings: appSettings)
try await alternateRoomSummaryProvider?.setRoomList(roomListService.allRooms())
self.syncService = syncService
@@ -24,6 +24,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
private let name: String
private let shouldUpdateVisibleRange: Bool
private let notificationSettings: NotificationSettingsProxyProtocol
private let appSettings: AppSettings
private let roomListPageSize = 200
@@ -65,13 +66,15 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
eventStringBuilder: RoomEventStringBuilder,
name: String,
shouldUpdateVisibleRange: Bool = false,
notificationSettings: NotificationSettingsProxyProtocol) {
notificationSettings: NotificationSettingsProxyProtocol,
appSettings: AppSettings) {
self.roomListService = roomListService
serialDispatchQueue = DispatchQueue(label: "io.element.elementx.roomsummaryprovider", qos: .default)
self.eventStringBuilder = eventStringBuilder
self.name = name
self.shouldUpdateVisibleRange = shouldUpdateVisibleRange
self.notificationSettings = notificationSettings
self.appSettings = appSettings
diffsPublisher
.receive(on: serialDispatchQueue)
@@ -148,7 +151,11 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
case .excludeAll:
_ = listUpdatesSubscriptionResult?.controller.setFilter(kind: .none)
case let .search(query):
let filters: [RoomListEntriesDynamicFilterKind] = [.normalizedMatchRoomName(pattern: query), .nonLeft]
let filters: [RoomListEntriesDynamicFilterKind] = if appSettings.fuzzyRoomListSearchEnabled {
[.fuzzyMatchRoomName(pattern: query), .nonLeft]
} else {
[.normalizedMatchRoomName(pattern: query), .nonLeft]
}
_ = listUpdatesSubscriptionResult?.controller.setFilter(kind: .all(filters: filters))
case let .all(filters):
var filters = filters.map(\.rustFilter)
@@ -148,7 +148,8 @@ class UserSessionStore: UserSessionStoreProtocol {
private func setupProxyForClient(_ client: Client) async -> ClientProxyProtocol {
await ClientProxy(client: client,
networkMonitor: ServiceLocator.shared.networkMonitor)
networkMonitor: ServiceLocator.shared.networkMonitor,
appSettings: ServiceLocator.shared.settings)
}
private func deleteSessionDirectory(for credentials: KeychainCredentials) {