From 8f999a462e495f38286481eb158a6e0db548ce5c Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 17 Mar 2023 17:52:57 +0100 Subject: [PATCH] Do not open long content when XOR is disabled --- .../Views/EndpointAdvancedView+OpenVPN.swift | 34 +++++++++++-------- .../AppShared/L10n/OpenVPN+L10n.swift | 5 +-- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift b/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift index f414533d..c8a72880 100644 --- a/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift +++ b/Passepartout/App/Views/EndpointAdvancedView+OpenVPN.swift @@ -141,13 +141,16 @@ extension EndpointAdvancedView.OpenVPNView { Text(L10n.Endpoint.Advanced.Openvpn.Items.Digest.caption) .withTrailingText($0.localizedDescription) } -// Text(Unlocalized.VPN.xor) -// .withTrailingText(settings.xor.localizedDescription) - themeLongContentLink( - Unlocalized.VPN.xor, - content: .constant(settings.xor.localizedLongDescription), - withPreview: settings.xor.localizedDescription - ) + if let xor = settings.xor { + themeLongContentLink( + Unlocalized.VPN.xor, + content: .constant(xor.localizedLongDescription), + withPreview: xor.localizedDescription + ) + } else { + Text(Unlocalized.VPN.xor) + .withTrailingText(L10n.Global.Strings.disabled) + } } header: { Text(L10n.Endpoint.Advanced.Openvpn.Sections.Communication.header) } @@ -168,13 +171,16 @@ extension EndpointAdvancedView.OpenVPNView { values: OpenVPN.Digest.available, description: \.localizedDescription ) -// Text(Unlocalized.VPN.xor) -// .withTrailingText(builder.xorMethod.localizedDescription) - themeLongContentLink( - Unlocalized.VPN.xor, - content: .constant(builder.xorMethod.localizedLongDescription), - withPreview: builder.xorMethod.localizedDescription - ) + if let xor = builder.xorMethod { + themeLongContentLink( + Unlocalized.VPN.xor, + content: .constant(xor.localizedLongDescription), + withPreview: xor.localizedDescription + ) + } else { + Text(Unlocalized.VPN.xor) + .withTrailingText(L10n.Global.Strings.disabled) + } } header: { Text(L10n.Endpoint.Advanced.Openvpn.Sections.Communication.header) } diff --git a/Passepartout/AppShared/L10n/OpenVPN+L10n.swift b/Passepartout/AppShared/L10n/OpenVPN+L10n.swift index 0efdf12b..9bf659f5 100644 --- a/Passepartout/AppShared/L10n/OpenVPN+L10n.swift +++ b/Passepartout/AppShared/L10n/OpenVPN+L10n.swift @@ -85,11 +85,8 @@ extension Optional where Wrapped == OpenVPN.TLSWrap { } } -extension Optional where Wrapped == OpenVPN.XORMethod { +extension OpenVPN.XORMethod { var localizedDescription: String { - guard let self = self else { - return L10n.Global.Strings.disabled - } switch self { case .xormask: return Unlocalized.OpenVPN.XOR.xormask.rawValue