mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
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:
@@ -43,8 +43,8 @@ extension RoomSummaryProviderMock {
|
|||||||
|
|
||||||
setFilterClosure = { [initialRooms, roomListSubject] filter in
|
setFilterClosure = { [initialRooms, roomListSubject] filter in
|
||||||
switch filter {
|
switch filter {
|
||||||
case let .search(query):
|
case let .search(query, joinedOnly):
|
||||||
var rooms = initialRooms
|
var rooms = joinedOnly ? initialRooms.filter { $0.joinRequestType == nil } : initialRooms
|
||||||
|
|
||||||
if !query.isEmpty {
|
if !query.isEmpty {
|
||||||
rooms = rooms.filter { $0.name.localizedCaseInsensitiveContains(query) }
|
rooms = rooms.filter { $0.name.localizedCaseInsensitiveContains(query) }
|
||||||
|
|||||||
@@ -153,12 +153,8 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
|||||||
switch filter {
|
switch filter {
|
||||||
case .excludeAll:
|
case .excludeAll:
|
||||||
_ = listUpdatesSubscriptionResult?.controller().setFilter(kind: .none)
|
_ = listUpdatesSubscriptionResult?.controller().setFilter(kind: .none)
|
||||||
case let .search(query):
|
case let .search(query, joinedOnly):
|
||||||
let filters = if appSettings.fuzzyRoomListSearchEnabled {
|
let filters = nameFilter(for: query) + baseFilter + (joinedOnly ? [.joined] : [])
|
||||||
[.fuzzyMatchRoomName(pattern: query)] + baseFilter
|
|
||||||
} else {
|
|
||||||
[.normalizedMatchRoomName(pattern: query)] + baseFilter
|
|
||||||
}
|
|
||||||
_ = listUpdatesSubscriptionResult?.controller().setFilter(kind: .all(filters: filters))
|
_ = listUpdatesSubscriptionResult?.controller().setFilter(kind: .all(filters: filters))
|
||||||
case .rooms(let roomIDs, let filters):
|
case .rooms(let roomIDs, let filters):
|
||||||
var rustFilters = filters.map(\.rustFilter) + baseFilter
|
var rustFilters = filters.map(\.rustFilter) + baseFilter
|
||||||
@@ -183,6 +179,10 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
|||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
|
private func nameFilter(for query: String) -> [RoomListEntriesDynamicFilterKind] {
|
||||||
|
appSettings.fuzzyRoomListSearchEnabled ? [.fuzzyMatchRoomName(pattern: query)] : [.normalizedMatchRoomName(pattern: query)]
|
||||||
|
}
|
||||||
|
|
||||||
private func setupVisibleRangeObservers() {
|
private func setupVisibleRangeObservers() {
|
||||||
// Unthrottled to add another page half way through the last one
|
// Unthrottled to add another page half way through the last one
|
||||||
visibleItemRangePublisher
|
visibleItemRangePublisher
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ enum RoomSummaryProviderState {
|
|||||||
enum RoomSummaryProviderFilter: Equatable {
|
enum RoomSummaryProviderFilter: Equatable {
|
||||||
/// Filters out everything
|
/// Filters out everything
|
||||||
case excludeAll
|
case excludeAll
|
||||||
/// Includes only the items that satisfy the predicate logic
|
/// Includes only the items that satisfy the predicate logic, optionally restricted to joined rooms
|
||||||
case search(query: String)
|
case search(query: String, joinedOnly: Bool = false)
|
||||||
/// Includes only what satisfies the filters used
|
/// Includes only what satisfies the filters used
|
||||||
case all(filters: Set<RoomListFilter>)
|
case all(filters: Set<RoomListFilter>)
|
||||||
/// Include only rooms from the given that satisfy the given filters
|
/// Include only rooms from the given that satisfy the given filters
|
||||||
|
|||||||
Reference in New Issue
Block a user