Skip to content

Commit fc8e92e

Browse files
committed
Separated encrypted from non-encrypted rooms. Moved DMs to the bottom.
1 parent d0f8835 commit fc8e92e

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

ElementX/Sources/Screens/HomeScreen/HomeScreenModels.swift

+12-8
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,24 @@ struct HomeScreenViewState: BindableState {
3737
var rooms: [HomeScreenRoom] = []
3838
var isLoadingRooms: Bool = false
3939

40-
var firstDirectRooms: [HomeScreenRoom] {
41-
Array(rooms.filter { $0.isDirect }.prefix(5))
40+
var sortedRooms: [HomeScreenRoom] {
41+
rooms.sorted(by: { ($0.displayName ?? $0.id).lowercased() < ($1.displayName ?? $1.id).lowercased() })
4242
}
4343

44-
var otherDirectRooms: [HomeScreenRoom] {
45-
Array(rooms.filter { $0.isDirect }.dropFirst(5))
44+
var unencryptedDMs: [HomeScreenRoom] {
45+
Array(sortedRooms.filter { $0.isDirect && !$0.isEncrypted })
4646
}
4747

48-
var firstNondirectRooms: [HomeScreenRoom] {
49-
Array(rooms.filter { !$0.isDirect }.prefix(5))
48+
var encryptedDMs: [HomeScreenRoom] {
49+
Array(sortedRooms.filter { $0.isDirect && $0.isEncrypted})
5050
}
5151

52-
var otherNondirectRooms: [HomeScreenRoom] {
53-
Array(rooms.filter { !$0.isDirect }.dropFirst(5))
52+
var unencryptedRooms: [HomeScreenRoom] {
53+
Array(sortedRooms.filter { !$0.isDirect && !$0.isEncrypted })
54+
}
55+
56+
var encryptedRooms: [HomeScreenRoom] {
57+
Array(sortedRooms.filter { !$0.isDirect && $0.isEncrypted })
5458
}
5559
}
5660

ElementX/Sources/Screens/HomeScreen/View/HomeScreen.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ struct HomeScreen: View {
3333
}
3434
} else {
3535
List {
36-
Section("People") {
37-
ForEach(context.viewState.firstDirectRooms) { room in
36+
Section("Rooms") {
37+
ForEach(context.viewState.unencryptedRooms) { room in
3838
RoomCell(room: room, context: context)
3939
}
4040

41-
let other = context.viewState.otherDirectRooms
41+
let other = context.viewState.encryptedRooms
4242

4343
if other.count > 0 {
44-
DisclosureGroup("See more") {
44+
DisclosureGroup("Encrypted") {
4545
ForEach(other) { room in
4646
RoomCell(room: room, context: context)
4747
}
4848
}
4949
}
5050
}
5151

52-
Section("Rooms") {
53-
ForEach(context.viewState.firstNondirectRooms) { room in
52+
Section("People") {
53+
ForEach(context.viewState.unencryptedDMs) { room in
5454
RoomCell(room: room, context: context)
5555
}
5656

57-
let other = context.viewState.otherNondirectRooms
57+
let other = context.viewState.encryptedDMs
5858

5959
if other.count > 0 {
60-
DisclosureGroup("See more") {
60+
DisclosureGroup("Encrypted") {
6161
ForEach(other) { room in
6262
RoomCell(room: room, context: context)
6363
}

0 commit comments

Comments
 (0)