fix search
This commit is contained in:
parent
2baf7ae2cb
commit
24f8ef9c55
@ -3,54 +3,4 @@
|
||||
uuid = "AEE1609A-17B4-4FCC-80A6-0D556940F4D7"
|
||||
type = "1"
|
||||
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>
|
||||
|
||||
@ -171,6 +171,7 @@ struct ChatProfile: Decodable {
|
||||
let permissions: ChatPermissions?
|
||||
let profilePermissions: ChatProfilePermissions?
|
||||
let relationship: RelationshipStatus?
|
||||
let isOfficial: Bool
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case userId
|
||||
@ -184,6 +185,8 @@ struct ChatProfile: Decodable {
|
||||
case permissions
|
||||
case profilePermissions
|
||||
case relationship
|
||||
case isOfficial
|
||||
case isVerified
|
||||
}
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
@ -199,6 +202,9 @@ struct ChatProfile: Decodable {
|
||||
self.permissions = try container.decodeIfPresent(ChatPermissions.self, forKey: .permissions)
|
||||
self.profilePermissions = try container.decodeIfPresent(ChatProfilePermissions.self, forKey: .profilePermissions)
|
||||
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] = [],
|
||||
permissions: ChatPermissions? = nil,
|
||||
profilePermissions: ChatProfilePermissions? = nil,
|
||||
relationship: RelationshipStatus? = nil
|
||||
relationship: RelationshipStatus? = nil,
|
||||
isOfficial: Bool = false
|
||||
) {
|
||||
self.userId = userId
|
||||
self.login = login
|
||||
@ -227,6 +234,7 @@ extension ChatProfile {
|
||||
self.permissions = permissions
|
||||
self.profilePermissions = profilePermissions
|
||||
self.relationship = relationship
|
||||
self.isOfficial = isOfficial
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -30,14 +30,14 @@ struct SearchProfile: Decodable {
|
||||
}
|
||||
|
||||
extension UserSearchResult {
|
||||
var officialFullName: String? {
|
||||
trimmed(profile?.fullName)
|
||||
}
|
||||
|
||||
var preferredCustomName: String? {
|
||||
trimmed(profile?.customName)
|
||||
}
|
||||
|
||||
var officialFullName: String? {
|
||||
trimmed(profile?.fullName)
|
||||
}
|
||||
|
||||
var login: String? {
|
||||
trimmed(profile?.login)
|
||||
}
|
||||
@ -63,8 +63,8 @@ extension UserSearchResult {
|
||||
}
|
||||
|
||||
var avatarInitial: String {
|
||||
let source = officialFullName
|
||||
?? preferredCustomName
|
||||
let source = preferredCustomName
|
||||
?? officialFullName
|
||||
?? login
|
||||
?? userId.uuidString
|
||||
|
||||
|
||||
@ -631,7 +631,7 @@ private extension ChatsTab {
|
||||
func chatProfile(from user: UserSearchResult) -> ChatProfile {
|
||||
let profile = user.profile
|
||||
let login = user.login ?? profile?.login
|
||||
let fullName = user.officialFullName ?? profile?.fullName
|
||||
let fullName = profile?.fullName
|
||||
let customName = user.preferredCustomName ?? profile?.customName
|
||||
|
||||
return ChatProfile(
|
||||
@ -641,7 +641,8 @@ private extension ChatsTab {
|
||||
customName: customName,
|
||||
bio: profile?.bio,
|
||||
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? {
|
||||
guard let login = chat.chatData?.login?.trimmingCharacters(in: .whitespacesAndNewlines), !login.isEmpty else {
|
||||
return nil
|
||||
@ -804,7 +798,21 @@ private struct ChatRowView: View {
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -868,19 +876,21 @@ private struct ChatRowView: View {
|
||||
let login = trimmed(profile.login)
|
||||
let customName = trimmed(profile.customName)
|
||||
let fullName = trimmed(profile.fullName)
|
||||
let isOfficialProfile = fullName != nil
|
||||
|
||||
if isOfficialProfile, let login {
|
||||
if let customName {
|
||||
return "@\(login) (\(customName))"
|
||||
}
|
||||
return "@\(login)"
|
||||
}
|
||||
let isOfficialProfile = profile.isOfficial
|
||||
|
||||
if let customName {
|
||||
return customName
|
||||
}
|
||||
|
||||
if isOfficialProfile {
|
||||
if let fullName {
|
||||
return fullName
|
||||
}
|
||||
if let login {
|
||||
return "@\(login)"
|
||||
}
|
||||
}
|
||||
|
||||
if let login {
|
||||
return "@\(login)"
|
||||
}
|
||||
@ -904,10 +914,12 @@ private struct ChatRowView: View {
|
||||
private var initial: String {
|
||||
let sourceName: String
|
||||
|
||||
if let full = officialFullName {
|
||||
sourceName = full
|
||||
} else if let custom = chat.chatData?.customName, !custom.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
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
|
||||
} else {
|
||||
@ -966,7 +978,7 @@ private struct ChatRowView: View {
|
||||
)
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
if let officialName = officialFullName {
|
||||
if let officialName = officialDisplayName {
|
||||
HStack(spacing: 6) {
|
||||
if #available(iOS 16.0, *) {
|
||||
Text(officialName)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user