mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Filter out space and tombstoned rooms from the rooms list.
This commit is contained in:
parent
5c7761e851
commit
d3588cf6f1
@ -35,10 +35,6 @@ struct HomeScreenViewState: BindableState {
|
||||
var rooms: [HomeScreenRoom] = []
|
||||
var isLoadingRooms: Bool = false
|
||||
|
||||
var sortedRooms: [HomeScreenRoom] {
|
||||
rooms.sorted(by: { ($0.displayName ?? $0.id).lowercased() < ($1.displayName ?? $1.id).lowercased() })
|
||||
}
|
||||
|
||||
var unencryptedDMs: [HomeScreenRoom] {
|
||||
Array(sortedRooms.filter { $0.isDirect && !$0.isEncrypted })
|
||||
}
|
||||
@ -54,6 +50,14 @@ struct HomeScreenViewState: BindableState {
|
||||
var encryptedRooms: [HomeScreenRoom] {
|
||||
Array(sortedRooms.filter { !$0.isDirect && $0.isEncrypted })
|
||||
}
|
||||
|
||||
private var filteredRooms: [HomeScreenRoom] {
|
||||
rooms.filter { !$0.isSpace && !$0.isTombstoned }
|
||||
}
|
||||
|
||||
private var sortedRooms: [HomeScreenRoom] {
|
||||
filteredRooms.sorted(by: { ($0.displayName ?? $0.id).lowercased() < ($1.displayName ?? $1.id).lowercased() })
|
||||
}
|
||||
}
|
||||
|
||||
struct HomeScreenRoom: Identifiable {
|
||||
@ -68,6 +72,8 @@ struct HomeScreenRoom: Identifiable {
|
||||
|
||||
let isDirect: Bool
|
||||
let isEncrypted: Bool
|
||||
let isSpace: Bool
|
||||
let isTombstoned: Bool
|
||||
}
|
||||
|
||||
extension MutableCollection where Element == HomeScreenRoom {
|
||||
|
@ -181,6 +181,8 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
topic: roomProxy.topic,
|
||||
lastMessage: roomProxy.lastMessage,
|
||||
isDirect: roomProxy.isDirect,
|
||||
isEncrypted: roomProxy.isEncrypted)
|
||||
isEncrypted: roomProxy.isEncrypted,
|
||||
isSpace: roomProxy.isSpace,
|
||||
isTombstoned: roomProxy.isTombstoned)
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ struct MockRoomProxy: RoomProxyProtocol {
|
||||
let isSpace = Bool.random()
|
||||
let isPublic = Bool.random()
|
||||
let isEncrypted = Bool.random()
|
||||
let isTombstoned = Bool.random()
|
||||
|
||||
var callbacks = PassthroughSubject<RoomProxyCallback, Never>()
|
||||
|
||||
|
@ -27,6 +27,7 @@ protocol RoomProxyProtocol {
|
||||
var isPublic: Bool { get }
|
||||
var isSpace: Bool { get }
|
||||
var isEncrypted: Bool { get }
|
||||
var isTombstoned: Bool { get }
|
||||
|
||||
var name: String? { get }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user