mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
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:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user