fix search

This commit is contained in:
cheykrym 2025-10-21 01:53:55 +03:00
parent 2baf7ae2cb
commit 24f8ef9c55
4 changed files with 49 additions and 79 deletions

View File

@ -3,54 +3,4 @@
uuid = "AEE1609A-17B4-4FCC-80A6-0D556940F4D7" uuid = "AEE1609A-17B4-4FCC-80A6-0D556940F4D7"
type = "1" type = "1"
version = "2.0"> version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "6A656809-A93B-45BB-9092-B1DBC8063EDE"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "yobble/Views/Tab/Settings/SettingsView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "158"
endingLineNumber = "158"
landmarkName = "selectTheme(_:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "084E94AC-6593-4982-9545-AD957522A99A"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "yobble/Views/Tab/Settings/SettingsView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "10"
endingLineNumber = "10"
landmarkName = "selectedThemeOption"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "93FB80BF-7B98-4DED-B22E-06C31F90EB0C"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "yobble/Views/Tab/Settings/SettingsView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "159"
endingLineNumber = "159"
landmarkName = "selectTheme(_:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket> </Bucket>

View File

@ -171,6 +171,7 @@ struct ChatProfile: Decodable {
let permissions: ChatPermissions? let permissions: ChatPermissions?
let profilePermissions: ChatProfilePermissions? let profilePermissions: ChatProfilePermissions?
let relationship: RelationshipStatus? let relationship: RelationshipStatus?
let isOfficial: Bool
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case userId case userId
@ -184,6 +185,8 @@ struct ChatProfile: Decodable {
case permissions case permissions
case profilePermissions case profilePermissions
case relationship case relationship
case isOfficial
case isVerified
} }
init(from decoder: Decoder) throws { init(from decoder: Decoder) throws {
@ -199,6 +202,9 @@ struct ChatProfile: Decodable {
self.permissions = try container.decodeIfPresent(ChatPermissions.self, forKey: .permissions) self.permissions = try container.decodeIfPresent(ChatPermissions.self, forKey: .permissions)
self.profilePermissions = try container.decodeIfPresent(ChatProfilePermissions.self, forKey: .profilePermissions) self.profilePermissions = try container.decodeIfPresent(ChatProfilePermissions.self, forKey: .profilePermissions)
self.relationship = try container.decodeIfPresent(RelationshipStatus.self, forKey: .relationship) self.relationship = try container.decodeIfPresent(RelationshipStatus.self, forKey: .relationship)
let explicitOfficial = try container.decodeIfPresent(Bool.self, forKey: .isOfficial)
let verifiedFlag = try container.decodeIfPresent(Bool.self, forKey: .isVerified)
self.isOfficial = explicitOfficial ?? verifiedFlag ?? false
} }
} }
@ -214,7 +220,8 @@ extension ChatProfile {
stories: [JSONValue] = [], stories: [JSONValue] = [],
permissions: ChatPermissions? = nil, permissions: ChatPermissions? = nil,
profilePermissions: ChatProfilePermissions? = nil, profilePermissions: ChatProfilePermissions? = nil,
relationship: RelationshipStatus? = nil relationship: RelationshipStatus? = nil,
isOfficial: Bool = false
) { ) {
self.userId = userId self.userId = userId
self.login = login self.login = login
@ -227,6 +234,7 @@ extension ChatProfile {
self.permissions = permissions self.permissions = permissions
self.profilePermissions = profilePermissions self.profilePermissions = profilePermissions
self.relationship = relationship self.relationship = relationship
self.isOfficial = isOfficial
} }
} }

View File

@ -30,14 +30,14 @@ struct SearchProfile: Decodable {
} }
extension UserSearchResult { extension UserSearchResult {
var officialFullName: String? {
trimmed(profile?.fullName)
}
var preferredCustomName: String? { var preferredCustomName: String? {
trimmed(profile?.customName) trimmed(profile?.customName)
} }
var officialFullName: String? {
trimmed(profile?.fullName)
}
var login: String? { var login: String? {
trimmed(profile?.login) trimmed(profile?.login)
} }
@ -63,8 +63,8 @@ extension UserSearchResult {
} }
var avatarInitial: String { var avatarInitial: String {
let source = officialFullName let source = preferredCustomName
?? preferredCustomName ?? officialFullName
?? login ?? login
?? userId.uuidString ?? userId.uuidString

View File

@ -631,7 +631,7 @@ private extension ChatsTab {
func chatProfile(from user: UserSearchResult) -> ChatProfile { func chatProfile(from user: UserSearchResult) -> ChatProfile {
let profile = user.profile let profile = user.profile
let login = user.login ?? profile?.login let login = user.login ?? profile?.login
let fullName = user.officialFullName ?? profile?.fullName let fullName = profile?.fullName
let customName = user.preferredCustomName ?? profile?.customName let customName = user.preferredCustomName ?? profile?.customName
return ChatProfile( return ChatProfile(
@ -641,7 +641,8 @@ private extension ChatsTab {
customName: customName, customName: customName,
bio: profile?.bio, bio: profile?.bio,
lastSeen: profile?.lastSeen, lastSeen: profile?.lastSeen,
createdAt: user.createdAt ?? profile?.createdAt createdAt: user.createdAt ?? profile?.createdAt,
isOfficial: user.isOfficial
) )
} }
@ -789,13 +790,6 @@ private struct ChatRowView: View {
} }
} }
private var officialFullName: String? {
guard let name = chat.chatData?.fullName?.trimmingCharacters(in: .whitespacesAndNewlines), !name.isEmpty else {
return nil
}
return NSLocalizedString(name, comment: "")
}
private var loginDisplay: String? { private var loginDisplay: String? {
guard let login = chat.chatData?.login?.trimmingCharacters(in: .whitespacesAndNewlines), !login.isEmpty else { guard let login = chat.chatData?.login?.trimmingCharacters(in: .whitespacesAndNewlines), !login.isEmpty else {
return nil return nil
@ -804,7 +798,21 @@ private struct ChatRowView: View {
} }
private var isOfficial: Bool { private var isOfficial: Bool {
officialFullName != nil chat.chatData?.isOfficial ?? false
}
private var officialDisplayName: String? {
guard isOfficial else { return nil }
if let customName = chat.chatData?.customName?.trimmingCharacters(in: .whitespacesAndNewlines), !customName.isEmpty {
return customName
}
if let name = chat.chatData?.fullName?.trimmingCharacters(in: .whitespacesAndNewlines), !name.isEmpty {
return NSLocalizedString(name, comment: "")
}
return loginDisplay
} }
private var isDeletedUser: Bool { private var isDeletedUser: Bool {
@ -868,19 +876,21 @@ private struct ChatRowView: View {
let login = trimmed(profile.login) let login = trimmed(profile.login)
let customName = trimmed(profile.customName) let customName = trimmed(profile.customName)
let fullName = trimmed(profile.fullName) let fullName = trimmed(profile.fullName)
let isOfficialProfile = fullName != nil let isOfficialProfile = profile.isOfficial
if isOfficialProfile, let login {
if let customName {
return "@\(login) (\(customName))"
}
return "@\(login)"
}
if let customName { if let customName {
return customName return customName
} }
if isOfficialProfile {
if let fullName {
return fullName
}
if let login {
return "@\(login)"
}
}
if let login { if let login {
return "@\(login)" return "@\(login)"
} }
@ -904,10 +914,12 @@ private struct ChatRowView: View {
private var initial: String { private var initial: String {
let sourceName: String let sourceName: String
if let full = officialFullName { if let custom = chat.chatData?.customName, !custom.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
sourceName = full
} else if let custom = chat.chatData?.customName, !custom.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
sourceName = custom 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 { } else if let login = chat.chatData?.login?.trimmingCharacters(in: .whitespacesAndNewlines), !login.isEmpty {
sourceName = login sourceName = login
} else { } else {
@ -966,7 +978,7 @@ private struct ChatRowView: View {
) )
VStack(alignment: .leading, spacing: 4) { VStack(alignment: .leading, spacing: 4) {
if let officialName = officialFullName { if let officialName = officialDisplayName {
HStack(spacing: 6) { HStack(spacing: 6) {
if #available(iOS 16.0, *) { if #available(iOS 16.0, *) {
Text(officialName) Text(officialName)