mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-01-22 08:32:11 +00:00
Verify sharing/TV features only on profile save (#1023)
Do not verify sharing/TV on connect iOS/macOS.
This commit is contained in:
parent
47b0b79fd7
commit
2eca757dc6
@ -136,7 +136,7 @@ private extension ProfileCoordinator {
|
||||
func onCommitEditingStandard() async throws {
|
||||
let savedProfile = try await profileEditor.save(to: profileManager, preferencesManager: preferencesManager)
|
||||
do {
|
||||
try iapManager.verify(savedProfile, isShared: profileEditor.isShared)
|
||||
try iapManager.verify(savedProfile, extra: profileEditor.extraFeatures)
|
||||
} catch AppError.ineligibleProfile(let requiredFeatures) {
|
||||
paywallReason = .init(requiredFeatures, needsConfirmation: true)
|
||||
return
|
||||
@ -147,7 +147,7 @@ private extension ProfileCoordinator {
|
||||
// restricted: verify before saving
|
||||
func onCommitEditingRestricted() async throws {
|
||||
do {
|
||||
try iapManager.verify(profileEditor.activeModules, isShared: profileEditor.isShared)
|
||||
try iapManager.verify(profileEditor.activeModules, extra: profileEditor.extraFeatures)
|
||||
} catch AppError.ineligibleProfile(let requiredFeatures) {
|
||||
paywallReason = .init(requiredFeatures)
|
||||
return
|
||||
@ -162,6 +162,19 @@ private extension ProfileCoordinator {
|
||||
}
|
||||
}
|
||||
|
||||
private extension ProfileEditor {
|
||||
var extraFeatures: Set<AppFeature> {
|
||||
var list: Set<AppFeature> = []
|
||||
if isShared {
|
||||
list.insert(.sharing)
|
||||
}
|
||||
if isAvailableForTV {
|
||||
list.insert(.appleTV)
|
||||
}
|
||||
return list
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
#Preview {
|
||||
|
@ -34,11 +34,7 @@ extension Profile: AppFeatureRequiring {
|
||||
}
|
||||
return builder
|
||||
}
|
||||
var requirements = builders.features
|
||||
if attributes.isAvailableForTV == true {
|
||||
requirements.insert(.appleTV)
|
||||
}
|
||||
return requirements
|
||||
return builders.features
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,18 +27,18 @@ import Foundation
|
||||
import PassepartoutKit
|
||||
|
||||
extension IAPManager {
|
||||
public func verify(_ profile: Profile, isShared: Bool = false) throws {
|
||||
public func verify(_ profile: Profile, extra: Set<AppFeature>? = nil) throws {
|
||||
var features = profile.features
|
||||
if isShared {
|
||||
features.insert(.sharing)
|
||||
extra?.forEach {
|
||||
features.insert($0)
|
||||
}
|
||||
try verify(features)
|
||||
}
|
||||
|
||||
public func verify(_ modulesBuilders: [any ModuleBuilder], isShared: Bool = false) throws {
|
||||
public func verify(_ modulesBuilders: [any ModuleBuilder], extra: Set<AppFeature>? = nil) throws {
|
||||
var features = modulesBuilders.features
|
||||
if isShared {
|
||||
features.insert(.sharing)
|
||||
extra?.forEach {
|
||||
features.insert($0)
|
||||
}
|
||||
try verify(features)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user