patch display without avatars
This commit is contained in:
parent
4ee1e20527
commit
fd96ca7cbc
@ -63,14 +63,27 @@ extension UserSearchResult {
|
||||
}
|
||||
|
||||
var avatarInitial: String {
|
||||
let source = preferredCustomName
|
||||
?? officialFullName
|
||||
?? login
|
||||
?? userId.uuidString
|
||||
|
||||
if let character = source.first(where: { !$0.isWhitespace && $0 != "@" }) {
|
||||
return String(character).uppercased()
|
||||
let nameSource: String?
|
||||
if let customName = preferredCustomName, !customName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
nameSource = customName
|
||||
} else if let fullName = officialFullName, !fullName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
nameSource = fullName
|
||||
} else {
|
||||
nameSource = nil
|
||||
}
|
||||
|
||||
if let name = nameSource {
|
||||
let components = name.split(separator: " ")
|
||||
let nameInitials = components.prefix(2).compactMap { $0.first }
|
||||
if !nameInitials.isEmpty {
|
||||
return nameInitials.map { String($0) }.joined().uppercased()
|
||||
}
|
||||
}
|
||||
|
||||
if let login = login, !login.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
return String(login.prefix(1)).uppercased()
|
||||
}
|
||||
|
||||
return "?"
|
||||
}
|
||||
|
||||
|
||||
@ -976,22 +976,25 @@ private struct ChatRowView: View {
|
||||
}
|
||||
|
||||
private var initial: String {
|
||||
let sourceName: String
|
||||
|
||||
if let custom = chat.chatData?.customName, !custom.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
sourceName = custom
|
||||
} else if let displayName = officialDisplayName {
|
||||
sourceName = displayName
|
||||
} else if let full = chat.chatData?.fullName?.trimmingCharacters(in: .whitespacesAndNewlines), !full.isEmpty {
|
||||
sourceName = full
|
||||
} else if let login = chat.chatData?.login?.trimmingCharacters(in: .whitespacesAndNewlines), !login.isEmpty {
|
||||
sourceName = login
|
||||
let nameSource: String?
|
||||
if let customName = chat.chatData?.customName, !customName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
nameSource = customName
|
||||
} else if let fullName = chat.chatData?.fullName, !fullName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
nameSource = fullName
|
||||
} else {
|
||||
sourceName = NSLocalizedString("Неизвестный пользователь", comment: "")
|
||||
nameSource = nil
|
||||
}
|
||||
|
||||
if let character = sourceName.first(where: { !$0.isWhitespace && $0 != "@" }) {
|
||||
return String(character).uppercased()
|
||||
if let name = nameSource {
|
||||
let components = name.split(separator: " ")
|
||||
let nameInitials = components.prefix(2).compactMap { $0.first }
|
||||
if !nameInitials.isEmpty {
|
||||
return nameInitials.map { String($0) }.joined().uppercased()
|
||||
}
|
||||
}
|
||||
|
||||
if let login = chat.chatData?.login, !login.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
return String(login.prefix(1)).uppercased()
|
||||
}
|
||||
|
||||
return "?"
|
||||
|
||||
@ -295,20 +295,24 @@ private struct Contact: Identifiable, Equatable {
|
||||
let handle: String?
|
||||
|
||||
var initials: String {
|
||||
let components = displayName.split(separator: " ")
|
||||
let nameSource: String?
|
||||
if let customName, !customName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
nameSource = customName
|
||||
} else if let fullName, !fullName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
nameSource = fullName
|
||||
} else {
|
||||
nameSource = nil
|
||||
}
|
||||
|
||||
if let name = nameSource {
|
||||
let components = name.split(separator: " ")
|
||||
let nameInitials = components.prefix(2).compactMap { $0.first }
|
||||
if !nameInitials.isEmpty {
|
||||
return nameInitials
|
||||
.map { String($0).uppercased() }
|
||||
.joined()
|
||||
return nameInitials.map { String($0) }.joined().uppercased()
|
||||
}
|
||||
}
|
||||
|
||||
let filtered = login.filter { $0.isLetter }.prefix(2)
|
||||
if !filtered.isEmpty {
|
||||
return filtered.uppercased()
|
||||
}
|
||||
|
||||
return "??"
|
||||
return String(login.prefix(1)).uppercased()
|
||||
}
|
||||
|
||||
var formattedCreatedAt: String {
|
||||
|
||||
@ -227,22 +227,24 @@ private struct BlockedUser: Identifiable, Equatable {
|
||||
private(set) var handle: String?
|
||||
|
||||
var initials: String {
|
||||
let components = displayName.split(separator: " ")
|
||||
let nameSource: String?
|
||||
if let customName, !customName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
nameSource = customName
|
||||
} else if let fullName, !fullName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
nameSource = fullName
|
||||
} else {
|
||||
nameSource = nil
|
||||
}
|
||||
|
||||
if let name = nameSource {
|
||||
let components = name.split(separator: " ")
|
||||
let nameInitials = components.prefix(2).compactMap { $0.first }
|
||||
if !nameInitials.isEmpty {
|
||||
return nameInitials
|
||||
.map { String($0).uppercased() }
|
||||
.joined()
|
||||
}
|
||||
|
||||
if let handle {
|
||||
let filtered = handle.filter { $0.isLetter }.prefix(2)
|
||||
if !filtered.isEmpty {
|
||||
return filtered.uppercased()
|
||||
return nameInitials.map { String($0) }.joined().uppercased()
|
||||
}
|
||||
}
|
||||
|
||||
return "??"
|
||||
return String(login.prefix(1)).uppercased()
|
||||
}
|
||||
|
||||
init(payload: BlockedUserInfo) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user