Rename properties and sort members in advance.

This commit is contained in:
Doug
2026-08-03 12:16:19 +01:00
committed by Doug
parent 3ab0aacabf
commit 1e78825b0b
18 changed files with 49 additions and 47 deletions
@@ -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