Fixes #2706 - Use disambiguated display names for timeline item senders and state event bodies. (#2739)

This commit is contained in:
Stefan Ceriu
2024-04-25 14:53:18 +03:00
committed by GitHub
parent 6661c16154
commit 8d66572cc9
7 changed files with 84 additions and 50 deletions
@@ -21,11 +21,21 @@ struct TimelineItemSender: Identifiable, Hashable {
let id: String
let displayName: String?
let isDisplayNameAmbiguous: Bool
let avatarURL: URL?
init(id: String, displayName: String? = nil, avatarURL: URL? = nil) {
init(id: String, displayName: String? = nil, isDisplayNameAmbiguous: Bool = false, avatarURL: URL? = nil) {
self.id = id
self.displayName = displayName
self.isDisplayNameAmbiguous = isDisplayNameAmbiguous
self.avatarURL = avatarURL
}
var disambiguatedDisplayName: String? {
guard let displayName else {
return nil
}
return isDisplayNameAmbiguous ? "\(displayName) (\(id))" : displayName
}
}