Fix room list heroes label format

- change from `Alice, Bob and Charlie` to `Alice, Bob, Charlie and 42 others` (when applicable)
This commit is contained in:
Stefan Ceriu
2025-05-12 09:39:53 +03:00
parent 876618d557
commit e1984ccdc0
42 changed files with 569 additions and 534 deletions
@@ -38,7 +38,10 @@ struct RoomSummary {
let name: String
let isDirect: Bool
let avatarURL: URL?
let heroes: [UserProfileProxy]
let activeMembersCount: UInt
let lastMessage: AttributedString?
let lastMessageDate: Date?
let unreadMessagesCount: UInt
@@ -81,7 +84,18 @@ extension RoomSummary: CustomStringConvertible {
return alias
}
return heroes.compactMap(\.displayName).formatted(.list(type: .and))
guard heroes.count > 0 else {
return ""
}
var heroComponents = heroes.compactMap(\.displayName)
let othersCount = Int(activeMembersCount) - heroes.count
if othersCount > 0 {
heroComponents.append(L10n.commonManyMembers(othersCount))
}
return heroComponents.formatted(.list(type: .and))
}
}
@@ -93,7 +107,10 @@ extension RoomSummary {
name = string
isDirect = true
avatarURL = nil
heroes = []
activeMembersCount = 0
lastMessage = AttributedString(string)
lastMessageDate = .mock
unreadMessagesCount = hasUnreadMessages ? 1 : 0
@@ -270,6 +270,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
isDirect: roomInfo.isDirect,
avatarURL: roomInfo.avatarUrl.flatMap(URL.init(string:)),
heroes: roomInfo.heroes.map(UserProfileProxy.init),
activeMembersCount: UInt(roomInfo.activeMembersCount),
lastMessage: attributedLastMessage,
lastMessageDate: lastMessageDate,
unreadMessagesCount: UInt(roomInfo.numUnreadMessages),