Make category optional in server long description

This commit is contained in:
Davide De Rosa 2023-03-17 18:09:21 +01:00
parent 8f999a462e
commit 26c34638cb
4 changed files with 7 additions and 7 deletions

View File

@ -48,7 +48,7 @@ class IntentDispatcher {
intent.profileId = header.id.uuidString intent.profileId = header.id.uuidString
intent.providerFullName = providerFullName intent.providerFullName = providerFullName
intent.serverId = server.id intent.serverId = server.id
intent.serverName = server.localizedLongDescription intent.serverName = server.localizedLongDescription(withCategory: false)
return intent return intent
} }

View File

@ -72,7 +72,7 @@ class DefaultLightProviderServer: LightProviderServer {
init(_ server: ProviderServer) { init(_ server: ProviderServer) {
description = server.localizedShortDescriptionWithDefault description = server.localizedShortDescriptionWithDefault
longDescription = server.localizedLongDescription longDescription = server.localizedLongDescription(withCategory: false)
categoryName = server.categoryName categoryName = server.categoryName
locationId = server.locationId locationId = server.locationId
serverId = server.id serverId = server.id

View File

@ -107,7 +107,7 @@ extension ProfileView {
} }
private var currentProviderServerDescription: String? { private var currentProviderServerDescription: String? {
profile.providerServer(providerManager)?.localizedLongDescription profile.providerServer(providerManager)?.localizedLongDescription(withCategory: true)
} }
private var currentProviderCountryImage: Image? { private var currentProviderCountryImage: Image? {

View File

@ -93,16 +93,16 @@ extension ProviderServer {
localizedShortDescription ?? "\(L10n.Global.Strings.default) [\(apiId)]" localizedShortDescription ?? "\(L10n.Global.Strings.default) [\(apiId)]"
} }
var localizedLongDescription: String { func localizedLongDescription(withCategory: Bool) -> String {
var comps: [String] = [localizedCountry] var comps: [String] = [localizedCountry]
localizedShortDescription.map { localizedShortDescription.map {
comps.append($0) comps.append($0)
} }
let desc = comps.joined(separator: ", ") let desc = comps.joined(separator: ", ")
guard !categoryName.isEmpty else { if withCategory, !categoryName.isEmpty {
return desc return "\(categoryName.uppercased()): \(desc)"
} }
return "\(categoryName.uppercased()): \(desc)" return desc
} }
} }