mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +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 rooms: [HomeScreenRoom] = []
|
||||||
var isLoadingRooms: Bool = false
|
var isLoadingRooms: Bool = false
|
||||||
|
|
||||||
var firstDirectRooms: [HomeScreenRoom] {
|
var sortedRooms: [HomeScreenRoom] {
|
||||||
Array(rooms.filter { $0.isDirect }.prefix(5))
|
rooms.sorted(by: { ($0.displayName ?? $0.id).lowercased() < ($1.displayName ?? $1.id).lowercased() })
|
||||||
}
|
}
|
||||||
|
|
||||||
var otherDirectRooms: [HomeScreenRoom] {
|
var unencryptedDMs: [HomeScreenRoom] {
|
||||||
Array(rooms.filter { $0.isDirect }.dropFirst(5))
|
Array(sortedRooms.filter { $0.isDirect && !$0.isEncrypted })
|
||||||
}
|
}
|
||||||
|
|
||||||
var firstNondirectRooms: [HomeScreenRoom] {
|
var encryptedDMs: [HomeScreenRoom] {
|
||||||
Array(rooms.filter { !$0.isDirect }.prefix(5))
|
Array(sortedRooms.filter { $0.isDirect && $0.isEncrypted})
|
||||||
}
|
}
|
||||||
|
|
||||||
var otherNondirectRooms: [HomeScreenRoom] {
|
var unencryptedRooms: [HomeScreenRoom] {
|
||||||
Array(rooms.filter { !$0.isDirect }.dropFirst(5))
|
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 {
|
} else {
|
||||||
List {
|
List {
|
||||||
Section("People") {
|
Section("Rooms") {
|
||||||
ForEach(context.viewState.firstDirectRooms) { room in
|
ForEach(context.viewState.unencryptedRooms) { room in
|
||||||
RoomCell(room: room, context: context)
|
RoomCell(room: room, context: context)
|
||||||
}
|
}
|
||||||
|
|
||||||
let other = context.viewState.otherDirectRooms
|
let other = context.viewState.encryptedRooms
|
||||||
|
|
||||||
if other.count > 0 {
|
if other.count > 0 {
|
||||||
DisclosureGroup("See more") {
|
DisclosureGroup("Encrypted") {
|
||||||
ForEach(other) { room in
|
ForEach(other) { room in
|
||||||
RoomCell(room: room, context: context)
|
RoomCell(room: room, context: context)
|
||||||
}
|
}
|
||||||
@@ -49,15 +49,15 @@ struct HomeScreen: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Section("Rooms") {
|
Section("People") {
|
||||||
ForEach(context.viewState.firstNondirectRooms) { room in
|
ForEach(context.viewState.unencryptedDMs) { room in
|
||||||
RoomCell(room: room, context: context)
|
RoomCell(room: room, context: context)
|
||||||
}
|
}
|
||||||
|
|
||||||
let other = context.viewState.otherNondirectRooms
|
let other = context.viewState.encryptedDMs
|
||||||
|
|
||||||
if other.count > 0 {
|
if other.count > 0 {
|
||||||
DisclosureGroup("See more") {
|
DisclosureGroup("Encrypted") {
|
||||||
ForEach(other) { room in
|
ForEach(other) { room in
|
||||||
RoomCell(room: room, context: context)
|
RoomCell(room: room, context: context)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user