mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Separated encrypted from non-encrypted rooms. Moved DMs to the bottom.
This commit is contained in:
@@ -37,20 +37,24 @@ struct HomeScreenViewState: BindableState {
|
||||
var rooms: [HomeScreenRoom] = []
|
||||
var isLoadingRooms: Bool = false
|
||||
|
||||
var firstDirectRooms: [HomeScreenRoom] {
|
||||
Array(rooms.filter { $0.isDirect }.prefix(5))
|
||||
var sortedRooms: [HomeScreenRoom] {
|
||||
rooms.sorted(by: { ($0.displayName ?? $0.id).lowercased() < ($1.displayName ?? $1.id).lowercased() })
|
||||
}
|
||||
|
||||
var otherDirectRooms: [HomeScreenRoom] {
|
||||
Array(rooms.filter { $0.isDirect }.dropFirst(5))
|
||||
var unencryptedDMs: [HomeScreenRoom] {
|
||||
Array(sortedRooms.filter { $0.isDirect && !$0.isEncrypted })
|
||||
}
|
||||
|
||||
var firstNondirectRooms: [HomeScreenRoom] {
|
||||
Array(rooms.filter { !$0.isDirect }.prefix(5))
|
||||
var encryptedDMs: [HomeScreenRoom] {
|
||||
Array(sortedRooms.filter { $0.isDirect && $0.isEncrypted})
|
||||
}
|
||||
|
||||
var otherNondirectRooms: [HomeScreenRoom] {
|
||||
Array(rooms.filter { !$0.isDirect }.dropFirst(5))
|
||||
var unencryptedRooms: [HomeScreenRoom] {
|
||||
Array(sortedRooms.filter { !$0.isDirect && !$0.isEncrypted })
|
||||
}
|
||||
|
||||
var encryptedRooms: [HomeScreenRoom] {
|
||||
Array(sortedRooms.filter { !$0.isDirect && $0.isEncrypted })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,15 +33,15 @@ struct HomeScreen: View {
|
||||
}
|
||||
} else {
|
||||
List {
|
||||
Section("People") {
|
||||
ForEach(context.viewState.firstDirectRooms) { room in
|
||||
Section("Rooms") {
|
||||
ForEach(context.viewState.unencryptedRooms) { room in
|
||||
RoomCell(room: room, context: context)
|
||||
}
|
||||
|
||||
let other = context.viewState.otherDirectRooms
|
||||
let other = context.viewState.encryptedRooms
|
||||
|
||||
if other.count > 0 {
|
||||
DisclosureGroup("See more") {
|
||||
DisclosureGroup("Encrypted") {
|
||||
ForEach(other) { room in
|
||||
RoomCell(room: room, context: context)
|
||||
}
|
||||
@@ -49,15 +49,15 @@ struct HomeScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
Section("Rooms") {
|
||||
ForEach(context.viewState.firstNondirectRooms) { room in
|
||||
Section("People") {
|
||||
ForEach(context.viewState.unencryptedDMs) { room in
|
||||
RoomCell(room: room, context: context)
|
||||
}
|
||||
|
||||
let other = context.viewState.otherNondirectRooms
|
||||
let other = context.viewState.encryptedDMs
|
||||
|
||||
if other.count > 0 {
|
||||
DisclosureGroup("See more") {
|
||||
DisclosureGroup("Encrypted") {
|
||||
ForEach(other) { room in
|
||||
RoomCell(room: room, context: context)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user