From fd96ca7cbc7403ca52dc20071a2955120374b9fa Mon Sep 17 00:00:00 2001 From: cheykrym Date: Tue, 9 Dec 2025 22:12:24 +0300 Subject: [PATCH] patch display without avatars --- yobble/Network/SearchModels.swift | 27 +++++++++++----- yobble/Views/Tab/ChatsTab.swift | 31 ++++++++++--------- yobble/Views/Tab/ContactsTab.swift | 26 +++++++++------- .../Views/Tab/Settings/BlockedUsersView.swift | 26 +++++++++------- 4 files changed, 66 insertions(+), 44 deletions(-) diff --git a/yobble/Network/SearchModels.swift b/yobble/Network/SearchModels.swift index 1b4b115..8901a99 100644 --- a/yobble/Network/SearchModels.swift +++ b/yobble/Network/SearchModels.swift @@ -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 "?" } diff --git a/yobble/Views/Tab/ChatsTab.swift b/yobble/Views/Tab/ChatsTab.swift index 5c37bb8..3826582 100644 --- a/yobble/Views/Tab/ChatsTab.swift +++ b/yobble/Views/Tab/ChatsTab.swift @@ -976,24 +976,27 @@ 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 "?" } diff --git a/yobble/Views/Tab/ContactsTab.swift b/yobble/Views/Tab/ContactsTab.swift index 3ae993e..d6b28e1 100644 --- a/yobble/Views/Tab/ContactsTab.swift +++ b/yobble/Views/Tab/ContactsTab.swift @@ -295,20 +295,24 @@ private struct Contact: Identifiable, Equatable { let handle: String? var initials: String { - let components = displayName.split(separator: " ") - let nameInitials = components.prefix(2).compactMap { $0.first } - if !nameInitials.isEmpty { - return nameInitials - .map { String($0).uppercased() } - .joined() + 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 } - let filtered = login.filter { $0.isLetter }.prefix(2) - if !filtered.isEmpty { - return filtered.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() + } } - - return "??" + + return String(login.prefix(1)).uppercased() } var formattedCreatedAt: String { diff --git a/yobble/Views/Tab/Settings/BlockedUsersView.swift b/yobble/Views/Tab/Settings/BlockedUsersView.swift index c624063..dad00c4 100644 --- a/yobble/Views/Tab/Settings/BlockedUsersView.swift +++ b/yobble/Views/Tab/Settings/BlockedUsersView.swift @@ -227,22 +227,24 @@ private struct BlockedUser: Identifiable, Equatable { private(set) var handle: String? var initials: String { - let components = displayName.split(separator: " ") - let nameInitials = components.prefix(2).compactMap { $0.first } - if !nameInitials.isEmpty { - return nameInitials - .map { String($0).uppercased() } - .joined() + 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 handle { - let filtered = handle.filter { $0.isLetter }.prefix(2) - if !filtered.isEmpty { - return filtered.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() } } - - return "??" + + return String(login.prefix(1)).uppercased() } init(payload: BlockedUserInfo) {