From a41aa6d35ea83b2a914ee5c9fa14f3494b7bb272 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 7 Feb 2021 15:28:30 +0100 Subject: [PATCH] Prevent multi-platform purchase when redundant --- .../App/iOS/Scenes/Purchase/PurchaseViewController.swift | 2 +- .../App/macOS/Scenes/Purchase/PurchaseViewController.swift | 2 +- Passepartout/Core/Sources/Model/ProductManager.swift | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Passepartout/App/iOS/Scenes/Purchase/PurchaseViewController.swift b/Passepartout/App/iOS/Scenes/Purchase/PurchaseViewController.swift index d9739e74..661141a2 100644 --- a/Passepartout/App/iOS/Scenes/Purchase/PurchaseViewController.swift +++ b/Passepartout/App/iOS/Scenes/Purchase/PurchaseViewController.swift @@ -72,7 +72,7 @@ class PurchaseViewController: UITableViewController, StrongTableHost { }.sortedCaseInsensitive() platformVersionExtra = bullets.joined(separator: "\n") } - if let skFullVersion = pm.product(withIdentifier: .fullVersion) { + if !pm.hasPurchased(.fullVersion_macOS), let skFullVersion = pm.product(withIdentifier: .fullVersion) { self.skFullVersion = skFullVersion rows.append(.fullVersion) diff --git a/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift b/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift index 371e7402..32287638 100644 --- a/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift +++ b/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift @@ -80,7 +80,7 @@ class PurchaseViewController: NSViewController { }.sortedCaseInsensitive() platformVersionExtra = bullets.joined(separator: "\n") } - if let skFullVersion = pm.product(withIdentifier: .fullVersion) { + if !pm.hasPurchased(.fullVersion_iOS), let skFullVersion = pm.product(withIdentifier: .fullVersion) { self.skFullVersion = skFullVersion rows.append(.fullVersion) diff --git a/Passepartout/Core/Sources/Model/ProductManager.swift b/Passepartout/Core/Sources/Model/ProductManager.swift index 1693ac49..62e54dd7 100644 --- a/Passepartout/Core/Sources/Model/ProductManager.swift +++ b/Passepartout/Core/Sources/Model/ProductManager.swift @@ -232,6 +232,10 @@ public class ProductManager: NSObject { } } + public func hasPurchased(_ product: Product) -> Bool { + return purchasedFeatures.contains(product) + } + public func isCancelledPurchase(_ product: Product) -> Bool { return cancelledPurchases.contains(product) }