Add a joined only option to the room list search filter

The search filter now takes a joinedOnly flag, which appends the SDK's
joined filter so that invited and knocked rooms are excluded. It defaults
to false, leaving the existing callers unchanged.
This commit is contained in:
Stefan Ceriu
2026-09-10 17:22:53 +03:00
parent 942535e4fa
commit af202f3466
3 changed files with 10 additions and 10 deletions
@@ -153,12 +153,8 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
switch filter {
case .excludeAll:
_ = listUpdatesSubscriptionResult?.controller().setFilter(kind: .none)
case let .search(query):
let filters = if appSettings.fuzzyRoomListSearchEnabled {
[.fuzzyMatchRoomName(pattern: query)] + baseFilter
} else {
[.normalizedMatchRoomName(pattern: query)] + baseFilter
}
case let .search(query, joinedOnly):
let filters = nameFilter(for: query) + baseFilter + (joinedOnly ? [.joined] : [])
_ = listUpdatesSubscriptionResult?.controller().setFilter(kind: .all(filters: filters))
case .rooms(let roomIDs, let filters):
var rustFilters = filters.map(\.rustFilter) + baseFilter
@@ -183,6 +179,10 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
// MARK: - Private
private func nameFilter(for query: String) -> [RoomListEntriesDynamicFilterKind] {
appSettings.fuzzyRoomListSearchEnabled ? [.fuzzyMatchRoomName(pattern: query)] : [.normalizedMatchRoomName(pattern: query)]
}
private func setupVisibleRangeObservers() {
// Unthrottled to add another page half way through the last one
visibleItemRangePublisher
@@ -36,8 +36,8 @@ enum RoomSummaryProviderState {
enum RoomSummaryProviderFilter: Equatable {
/// Filters out everything
case excludeAll
/// Includes only the items that satisfy the predicate logic
case search(query: String)
/// Includes only the items that satisfy the predicate logic, optionally restricted to joined rooms
case search(query: String, joinedOnly: Bool = false)
/// Includes only what satisfies the filters used
case all(filters: Set<RoomListFilter>)
/// Include only rooms from the given that satisfy the given filters