From bafac12be4b47abc8863656ba0928c7afa1c726a Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Wed, 4 May 2022 23:14:16 +0200 Subject: [PATCH] Retain in beta profiles created in production Drop filter, ability to create profiles in the first place implies eligibility. --- Passepartout/App/Constants/AppContext.swift | 15 ------------- .../Managers/ProfileManager.swift | 21 ++++--------------- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/Passepartout/App/Constants/AppContext.swift b/Passepartout/App/Constants/AppContext.swift index 74976911..bff36be7 100644 --- a/Passepartout/App/Constants/AppContext.swift +++ b/Passepartout/App/Constants/AppContext.swift @@ -128,9 +128,6 @@ class AppContext { // core - profileManager.availabilityFilter = { - self.isEligibleProfile(withHeader: $0) - } providerManager.rateLimitMilliseconds = Constants.RateLimit.providerManager vpnManager.isOnDemandRulesSupported = { self.isEligibleForOnDemandRules() @@ -156,18 +153,6 @@ class AppContext { }.store(in: &cancellables) } - // eligibility: hide providers not found or not purchased - private func isEligibleProfile(withHeader header: Profile.Header) -> Bool { - guard let providerName = header.providerName else { - return true // always eligible for non-provider profiles - } - guard productManager.isEligible(forProvider: providerName) else { -// pp_log.debug("Not eligible for provider \(metadata.name)") - return false - } - return true - } - // eligibility: ignore network settings if ineligible private func isEligibleForNetworkSettings() -> Bool { guard productManager.isEligible(forFeature: .networkSettings) else { diff --git a/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift b/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift index 530f2c03..6a25aa16 100644 --- a/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift +++ b/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift @@ -45,8 +45,6 @@ public class ProfileManager: ObservableObject { private let strategy: ProfileManagerStrategy - public var availabilityFilter: ((Profile.Header) -> Bool)? - // MARK: Observables @Published public private(set) var activeProfileId: UUID? { @@ -118,19 +116,12 @@ extension ProfileManager { strategy.allHeaders } - private var availableHeaders: [Profile.Header] { - if let availabilityFilter = availabilityFilter { - return allHeaders.values.filter(availabilityFilter) - } - return Array(allHeaders.values) - } - public var headers: [Profile.Header] { - availableHeaders + Array(allHeaders.values) } public var hasProfiles: Bool { - !availableHeaders.isEmpty + !allHeaders.isEmpty } public var hasActiveProfile: Bool { @@ -141,12 +132,12 @@ extension ProfileManager { id == activeProfileId } - // existence in persistent storage (skips availability) + // existence in persistent storage public func isExistingProfile(withId id: UUID) -> Bool { allHeaders[id] != nil } - // existence in persistent storage (skips availability) + // existence in persistent storage public func isExistingProfile(withName name: String) -> Bool { allHeaders.contains { $0.value.name == name @@ -190,10 +181,6 @@ extension ProfileManager { assertionFailure("Profile in headers yet not found in persistent store") return nil } - guard availabilityFilter?(profile.header) ?? true else { - pp_log.warning("Profile \(profile.logDescription) not available due to filter") - return nil - } guard !profile.vpnProtocols.isEmpty else { assertionFailure("Ditching profile, no OpenVPN/WireGuard settings found") return nil