Retain in beta profiles created in production

Drop filter, ability to create profiles in the first place implies
eligibility.
This commit is contained in:
Davide De Rosa 2022-05-04 23:14:16 +02:00
parent c2676cbdf6
commit bafac12be4
2 changed files with 4 additions and 32 deletions

View File

@ -128,9 +128,6 @@ class AppContext {
// core // core
profileManager.availabilityFilter = {
self.isEligibleProfile(withHeader: $0)
}
providerManager.rateLimitMilliseconds = Constants.RateLimit.providerManager providerManager.rateLimitMilliseconds = Constants.RateLimit.providerManager
vpnManager.isOnDemandRulesSupported = { vpnManager.isOnDemandRulesSupported = {
self.isEligibleForOnDemandRules() self.isEligibleForOnDemandRules()
@ -156,18 +153,6 @@ class AppContext {
}.store(in: &cancellables) }.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 // eligibility: ignore network settings if ineligible
private func isEligibleForNetworkSettings() -> Bool { private func isEligibleForNetworkSettings() -> Bool {
guard productManager.isEligible(forFeature: .networkSettings) else { guard productManager.isEligible(forFeature: .networkSettings) else {

View File

@ -45,8 +45,6 @@ public class ProfileManager: ObservableObject {
private let strategy: ProfileManagerStrategy private let strategy: ProfileManagerStrategy
public var availabilityFilter: ((Profile.Header) -> Bool)?
// MARK: Observables // MARK: Observables
@Published public private(set) var activeProfileId: UUID? { @Published public private(set) var activeProfileId: UUID? {
@ -118,19 +116,12 @@ extension ProfileManager {
strategy.allHeaders 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] { public var headers: [Profile.Header] {
availableHeaders Array(allHeaders.values)
} }
public var hasProfiles: Bool { public var hasProfiles: Bool {
!availableHeaders.isEmpty !allHeaders.isEmpty
} }
public var hasActiveProfile: Bool { public var hasActiveProfile: Bool {
@ -141,12 +132,12 @@ extension ProfileManager {
id == activeProfileId id == activeProfileId
} }
// existence in persistent storage (skips availability) // existence in persistent storage
public func isExistingProfile(withId id: UUID) -> Bool { public func isExistingProfile(withId id: UUID) -> Bool {
allHeaders[id] != nil allHeaders[id] != nil
} }
// existence in persistent storage (skips availability) // existence in persistent storage
public func isExistingProfile(withName name: String) -> Bool { public func isExistingProfile(withName name: String) -> Bool {
allHeaders.contains { allHeaders.contains {
$0.value.name == name $0.value.name == name
@ -190,10 +181,6 @@ extension ProfileManager {
assertionFailure("Profile in headers yet not found in persistent store") assertionFailure("Profile in headers yet not found in persistent store")
return nil 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 { guard !profile.vpnProtocols.isEmpty else {
assertionFailure("Ditching profile, no OpenVPN/WireGuard settings found") assertionFailure("Ditching profile, no OpenVPN/WireGuard settings found")
return nil return nil