mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Rename properties and sort members in advance.
This commit is contained in:
@@ -49,10 +49,15 @@ nonisolated extension RoomMemberProxyProtocol {
|
||||
}
|
||||
|
||||
nonisolated extension [RoomMemberProxyProtocol] {
|
||||
/// The members, sorted first by power-level, and then alphabetically within each power-level.
|
||||
func sorted() -> Self {
|
||||
/// The members, sorted first by call participation, then by power-level, and then alphabetically within each power-level.
|
||||
func sorted(prioritisingRoomCallParticipants roomCallParticipants: [String] = []) -> Self {
|
||||
sorted { lhs, rhs in
|
||||
if lhs.powerLevel != rhs.powerLevel {
|
||||
let lhsIsRoomCallParticipant = roomCallParticipants.contains(lhs.userID)
|
||||
let rhsIsRoomCallParticipant = roomCallParticipants.contains(rhs.userID)
|
||||
|
||||
return if lhsIsRoomCallParticipant != rhsIsRoomCallParticipant {
|
||||
lhsIsRoomCallParticipant
|
||||
} else if lhs.powerLevel != rhs.powerLevel {
|
||||
lhs.powerLevel > rhs.powerLevel
|
||||
} else {
|
||||
lhs.sortingName.localizedStandardCompare(rhs.sortingName) == .orderedAscending
|
||||
|
||||
Reference in New Issue
Block a user