Fix check for provider eligibility

This commit is contained in:
Davide De Rosa 2019-12-22 11:56:06 +01:00
parent 535caf4d37
commit c1854ffd00
2 changed files with 7 additions and 6 deletions

View File

@ -173,13 +173,11 @@ class ProductManager: NSObject {
return purchasedFeatures.contains(feature) return purchasedFeatures.contains(feature)
} }
func isEligible(forProvider name: Infrastructure.Name) -> Bool { func isEligible(forProvider metadata: Infrastructure.Metadata) -> Bool {
guard !isFullVersion() else { guard !isFullVersion() else {
return true return true
} }
return purchasedFeatures.contains { return purchasedFeatures.contains(metadata.product)
return $0.rawValue.hasSuffix("providers.\(name)")
}
} }
func isEligibleForFeedback() -> Bool { func isEligibleForFeedback() -> Bool {
@ -228,7 +226,10 @@ class ProductManager: NSObject {
log.debug("Checking providers") log.debug("Checking providers")
for name in service.currentProviderNames() { for name in service.currentProviderNames() {
if !isEligible(forProvider: name) { guard let metadata = InfrastructureFactory.shared.metadata(forName: name) else {
continue
}
if !isEligible(forProvider: metadata) {
service.removeProfile(ProfileKey(name)) service.removeProfile(ProfileKey(name))
log.debug("\tRefunded provider: \(name)") log.debug("\tRefunded provider: \(name)")
anyRefund = true anyRefund = true

View File

@ -63,7 +63,7 @@ class WizardProviderViewController: UITableViewController, StrongTableHost {
private func tryNext(withMetadata metadata: Infrastructure.Metadata) { private func tryNext(withMetadata metadata: Infrastructure.Metadata) {
selectedMetadata = metadata selectedMetadata = metadata
guard ProductManager.shared.isEligible(forProvider: metadata.name) else { guard ProductManager.shared.isEligible(forProvider: metadata) else {
presentPurchaseScreen(forProduct: metadata.product, delegate: self) presentPurchaseScreen(forProduct: metadata.product, delegate: self)
return return
} }