Skip to content

Commit

Permalink
Minor purchase change to distinguish using offline test products
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmhouston committed Oct 31, 2024
1 parent f7fe537 commit 3ec16e7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
36 changes: 18 additions & 18 deletions Cleepp/Purchases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,26 +156,26 @@ class Purchases: NSObject {
throw PurchaseError.prohibited
}

// fetchProducts(withIDs: knownProductIdentifiers) { [weak self] productsResult in
// guard let self = self else { return }
//
// switch productsResult {
// case .success(let products):
// callObservers(withUpdate: .success(.products(products)))
// case .failure(let error):
// callObservers(withUpdate: .failure(error))
// }
// }

// temp test code:
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) { [weak self] in
fetchProducts(withIDs: knownProductIdentifiers) { [weak self] productsResult in
guard let self = self else { return }
let productList = [
DummyProductDetail(identifier: Self.basicProductIdentifier, item: .bonus, localizedDescription: "Support us and unlock bonus features", localizedPrice: "$3.99", subscription: .not),
DummyProductDetail(identifier: Self.corporateProductIdentifier, item: .corporateSubscription, localizedDescription: "Corporate yearly subscription", localizedPrice: "$9.99", subscription: .yearly)
]
callObservers(withUpdate: .success(.products(productList)))

switch productsResult {
case .success(let products):
callObservers(withUpdate: .success(.products(products)))
case .failure(let error):
callObservers(withUpdate: .failure(error))
}
}

// // temp test code:
// DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { [weak self] in
// guard let self = self else { return }
// let productList = [
// DummyProductDetail(identifier: Self.basicProductIdentifier, item: .bonus, localizedDescription: "Support us and unlock bonus features", localizedPrice: "$3.99", subscription: .not),
// DummyProductDetail(identifier: Self.corporateProductIdentifier, item: .corporateSubscription, localizedDescription: "Corporate yearly subscription", localizedPrice: "$9.99", subscription: .yearly)
// ]
// callObservers(withUpdate: .success(.products(productList)))
// }
}

func startPurchase(_ product: ProductDetail) throws {
Expand Down
7 changes: 6 additions & 1 deletion Cleepp/Settings/PurchaseDetailWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ class PurchaseDetailWindowController: NSWindowController, NSWindowDelegate, NSTa
}

override func windowDidLoad() {
templateBuyButtonTitle = buyButton.title
if let product = products.first, product is Purchases.DummyProductDetail {
templateBuyButtonTitle = "Test, won't be charged $" // do not localize
} else {
templateBuyButtonTitle = buyButton.title
}
disabledBuyButtonTitle = buyButton.alternateTitle
buyButton.alternateTitle = ""

if purchases.isEmpty, let defaultSelectRow = products.firstIndex(where: { $0.item == .bonus }) {
let product = products[defaultSelectRow]
Expand Down

0 comments on commit 3ec16e7

Please sign in to comment.