File tree 2 files changed +20
-16
lines changed
ElementX/Sources/Screens/HomeScreen
2 files changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -37,20 +37,24 @@ struct HomeScreenViewState: BindableState {
37
37
var rooms : [ HomeScreenRoom ] = [ ]
38
38
var isLoadingRooms : Bool = false
39
39
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 ( ) } )
42
42
}
43
43
44
- var otherDirectRooms : [ HomeScreenRoom ] {
45
- Array ( rooms . filter { $0. isDirect } . dropFirst ( 5 ) )
44
+ var unencryptedDMs : [ HomeScreenRoom ] {
45
+ Array ( sortedRooms . filter { $0. isDirect && !$0 . isEncrypted } )
46
46
}
47
47
48
- var firstNondirectRooms : [ HomeScreenRoom ] {
49
- Array ( rooms . filter { ! $0. isDirect } . prefix ( 5 ) )
48
+ var encryptedDMs : [ HomeScreenRoom ] {
49
+ Array ( sortedRooms . filter { $0. isDirect && $0 . isEncrypted } )
50
50
}
51
51
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 } )
54
58
}
55
59
}
56
60
Original file line number Diff line number Diff line change @@ -33,31 +33,31 @@ struct HomeScreen: View {
33
33
}
34
34
} else {
35
35
List {
36
- Section ( " People " ) {
37
- ForEach ( context. viewState. firstDirectRooms ) { room in
36
+ Section ( " Rooms " ) {
37
+ ForEach ( context. viewState. unencryptedRooms ) { room in
38
38
RoomCell ( room: room, context: context)
39
39
}
40
40
41
- let other = context. viewState. otherDirectRooms
41
+ let other = context. viewState. encryptedRooms
42
42
43
43
if other. count > 0 {
44
- DisclosureGroup ( " See more " ) {
44
+ DisclosureGroup ( " Encrypted " ) {
45
45
ForEach ( other) { room in
46
46
RoomCell ( room: room, context: context)
47
47
}
48
48
}
49
49
}
50
50
}
51
51
52
- Section ( " Rooms " ) {
53
- ForEach ( context. viewState. firstNondirectRooms ) { room in
52
+ Section ( " People " ) {
53
+ ForEach ( context. viewState. unencryptedDMs ) { room in
54
54
RoomCell ( room: room, context: context)
55
55
}
56
56
57
- let other = context. viewState. otherNondirectRooms
57
+ let other = context. viewState. encryptedDMs
58
58
59
59
if other. count > 0 {
60
- DisclosureGroup ( " See more " ) {
60
+ DisclosureGroup ( " Encrypted " ) {
61
61
ForEach ( other) { room in
62
62
RoomCell ( room: room, context: context)
63
63
}
You can’t perform that action at this time.
0 commit comments