mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 08:15:24 +00:00
Ignore incompatible room filter activations
Signed-off-by: Sergey Ospanov <33452977+sergeyospanov@users.noreply.github.com>
This commit is contained in:
@@ -109,10 +109,8 @@ struct RoomListFiltersState {
|
||||
}
|
||||
|
||||
mutating func activateFilter(_ filter: RoomListFilter) {
|
||||
filter.incompatibleFilters.forEach { incompatibleFilter in
|
||||
if activeFilters.contains(incompatibleFilter) {
|
||||
fatalError("[RoomListFiltersState] adding mutually exclusive filters is not allowed")
|
||||
}
|
||||
if filter.incompatibleFilters.contains(where: { activeFilters.contains($0) }) {
|
||||
return
|
||||
}
|
||||
|
||||
// We always want the most recently enabled filter to be at the bottom of the others.
|
||||
|
||||
@@ -62,6 +62,14 @@ final class RoomListFiltersStateTests {
|
||||
#expect(state.availableFilters == [.favourites])
|
||||
}
|
||||
|
||||
@Test
|
||||
func ignoresIncompatibleFilter() {
|
||||
state.activateFilter(.people)
|
||||
state.activateFilter(.invites)
|
||||
|
||||
#expect(state.activeFilters == [.people])
|
||||
}
|
||||
|
||||
@Test
|
||||
func clearFilters() {
|
||||
state.activateFilter(.people)
|
||||
|
||||
Reference in New Issue
Block a user