From 17b01a4dbc4851f4497647f6a4ab83b53017802b Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 16 Mar 2023 14:08:47 +0100 Subject: [PATCH] Clean up some code - Drop stale generic - Improve readability --- Passepartout/App/Views/AddProviderView.swift | 6 +++--- .../Managers/TunnelKitVPNManagerStrategy.swift | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Passepartout/App/Views/AddProviderView.swift b/Passepartout/App/Views/AddProviderView.swift index 7e17788b..7fa666db 100644 --- a/Passepartout/App/Views/AddProviderView.swift +++ b/Passepartout/App/Views/AddProviderView.swift @@ -135,11 +135,11 @@ struct AddProviderView: View { // eligibility: select or purchase provider private func presentOrPurchaseProvider(_ metadata: ProviderMetadata) { - if productManager.isEligible(forProvider: metadata.name) { - viewModel.selectProvider(metadata, providerManager) - } else { + guard productManager.isEligible(forProvider: metadata.name) else { viewModel.presentPaywall() + return } + viewModel.selectProvider(metadata, providerManager) } private func onErrorMessage(_ message: String?, _ scrollProxy: ScrollViewProxy) { diff --git a/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/TunnelKitVPNManagerStrategy.swift b/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/TunnelKitVPNManagerStrategy.swift index ff9847e1..3da06fc5 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/TunnelKitVPNManagerStrategy.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/TunnelKitVPNManagerStrategy.swift @@ -32,7 +32,7 @@ import TunnelKitOpenVPNCore import PassepartoutCore import PassepartoutUtils -public class TunnelKitVPNManagerStrategy: VPNManagerStrategy where VPNType.Configuration == NetworkExtensionConfiguration, VPNType.Extra == NetworkExtensionExtra { +public class TunnelKitVPNManagerStrategy: VPNManagerStrategy { private struct AtomicState: Equatable { let isEnabled: Bool @@ -52,7 +52,7 @@ public class TunnelKitVPNManagerStrategy: VPNManagerStrategy where private let defaults: UserDefaults - private let vpn: VPNType + private let vpn: NetworkExtensionVPN private let dataCountInterval: TimeInterval @@ -73,7 +73,7 @@ public class TunnelKitVPNManagerStrategy: VPNManagerStrategy where public init( appGroup: String, tunnelBundleIdentifier: @escaping (VPNProtocolType) -> String, - vpn: VPNType, + vpn: NetworkExtensionVPN, dataCountInterval: TimeInterval = 3.0 ) { self.appGroup = appGroup