From 26c34638cb9ab746fc52fffc0714d20dc9a16d6b Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 17 Mar 2023 18:09:21 +0100 Subject: [PATCH] Make category optional in server long description --- Passepartout/App/Intents/IntentDispatcher.swift | 2 +- .../App/Mac/Models/DefaultLightProviderManager.swift | 2 +- Passepartout/App/Views/ProfileView+Provider.swift | 2 +- Passepartout/AppShared/L10n/Providers+L10n.swift | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Passepartout/App/Intents/IntentDispatcher.swift b/Passepartout/App/Intents/IntentDispatcher.swift index 594ee744..5f2e0d43 100644 --- a/Passepartout/App/Intents/IntentDispatcher.swift +++ b/Passepartout/App/Intents/IntentDispatcher.swift @@ -48,7 +48,7 @@ class IntentDispatcher { intent.profileId = header.id.uuidString intent.providerFullName = providerFullName intent.serverId = server.id - intent.serverName = server.localizedLongDescription + intent.serverName = server.localizedLongDescription(withCategory: false) return intent } diff --git a/Passepartout/App/Mac/Models/DefaultLightProviderManager.swift b/Passepartout/App/Mac/Models/DefaultLightProviderManager.swift index dc8620ed..6640cb82 100644 --- a/Passepartout/App/Mac/Models/DefaultLightProviderManager.swift +++ b/Passepartout/App/Mac/Models/DefaultLightProviderManager.swift @@ -72,7 +72,7 @@ class DefaultLightProviderServer: LightProviderServer { init(_ server: ProviderServer) { description = server.localizedShortDescriptionWithDefault - longDescription = server.localizedLongDescription + longDescription = server.localizedLongDescription(withCategory: false) categoryName = server.categoryName locationId = server.locationId serverId = server.id diff --git a/Passepartout/App/Views/ProfileView+Provider.swift b/Passepartout/App/Views/ProfileView+Provider.swift index 6ebce7f9..df837433 100644 --- a/Passepartout/App/Views/ProfileView+Provider.swift +++ b/Passepartout/App/Views/ProfileView+Provider.swift @@ -107,7 +107,7 @@ extension ProfileView { } private var currentProviderServerDescription: String? { - profile.providerServer(providerManager)?.localizedLongDescription + profile.providerServer(providerManager)?.localizedLongDescription(withCategory: true) } private var currentProviderCountryImage: Image? { diff --git a/Passepartout/AppShared/L10n/Providers+L10n.swift b/Passepartout/AppShared/L10n/Providers+L10n.swift index 0b618fed..58dd6eb7 100644 --- a/Passepartout/AppShared/L10n/Providers+L10n.swift +++ b/Passepartout/AppShared/L10n/Providers+L10n.swift @@ -93,16 +93,16 @@ extension ProviderServer { localizedShortDescription ?? "\(L10n.Global.Strings.default) [\(apiId)]" } - var localizedLongDescription: String { + func localizedLongDescription(withCategory: Bool) -> String { var comps: [String] = [localizedCountry] localizedShortDescription.map { comps.append($0) } let desc = comps.joined(separator: ", ") - guard !categoryName.isEmpty else { - return desc + if withCategory, !categoryName.isEmpty { + return "\(categoryName.uppercased()): \(desc)" } - return "\(categoryName.uppercased()): \(desc)" + return desc } }