From 838eb1c5897f69629dd47f21bda66fb67c22d6c4 Mon Sep 17 00:00:00 2001 From: Will Taylor Date: Mon, 16 Dec 2024 15:36:23 -0600 Subject: [PATCH] Revert "Always call readyForPromotedProduct on the main actor" --- Sources/Purchasing/Purchases/Purchases.swift | 8 +------ .../PurchasesDeferredPurchasesTests.swift | 21 +++++-------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/Sources/Purchasing/Purchases/Purchases.swift b/Sources/Purchasing/Purchases/Purchases.swift index 156fcba9d5..2996ad19d3 100644 --- a/Sources/Purchasing/Purchases/Purchases.swift +++ b/Sources/Purchasing/Purchases/Purchases.swift @@ -1597,13 +1597,7 @@ extension Purchases: PurchasesOrchestratorDelegate { */ func readyForPromotedProduct(_ product: StoreProduct, purchase startPurchase: @escaping StartPurchaseBlock) { - OperationDispatcher.dispatchOnMainActor { - self.delegate?.purchases?( - self, - readyForPromotedProduct: product, - purchase: startPurchase - ) - } + self.delegate?.purchases?(self, readyForPromotedProduct: product, purchase: startPurchase) } #if os(iOS) || targetEnvironment(macCatalyst) || VISION_OS diff --git a/Tests/UnitTests/Purchasing/Purchases/PurchasesDeferredPurchasesTests.swift b/Tests/UnitTests/Purchasing/Purchases/PurchasesDeferredPurchasesTests.swift index 5ca53ee962..ff2fc73790 100644 --- a/Tests/UnitTests/Purchasing/Purchases/PurchasesDeferredPurchasesTests.swift +++ b/Tests/UnitTests/Purchasing/Purchases/PurchasesDeferredPurchasesTests.swift @@ -42,12 +42,6 @@ class PurchaseDeferredPurchasesTests: BasePurchasesTests { shouldAddStorePayment: payment, for: self.product) - waitUntil { completed in - if self.purchasesDelegate.makeDeferredPurchase != nil { - completed() - } - } - expect(self.purchasesDelegate.makeDeferredPurchase).toNot(beNil()) expect(self.storeKit1Wrapper.payment).to(beNil()) @@ -65,12 +59,6 @@ class PurchaseDeferredPurchasesTests: BasePurchasesTests { shouldAddStorePayment: payment, for: self.product) - waitUntil { completed in - if self.purchasesDelegate.makeDeferredPurchase != nil { - completed() - } - } - expect(self.purchasesDelegate.makeDeferredPurchase).toNot(beNil()) expect(self.storeKit1Wrapper.payment).to(beNil()) @@ -99,7 +87,7 @@ class PurchaseDeferredPurchasesTests: BasePurchasesTests { shouldAddStorePayment: payment, for: self.product) - expect(self.purchasesDelegate.promoProduct).toEventually(equal(StoreProduct(sk1Product: self.product))) + expect(self.purchasesDelegate.promoProduct) == StoreProduct(sk1Product: self.product) } func testShouldAddStorePaymentReturnsFalseForNilProductIdentifier() throws { @@ -189,9 +177,10 @@ class PurchaseDeferredPurchasesSK2Tests: BasePurchasesTests { for: self.product ) - expect(self.purchasesDelegate.makeDeferredPurchase).toEventuallyNot(beNil()) - expect(self.purchasesDelegate.promoProduct).toEventually(equal(StoreProduct(sk1Product: self.product))) - expect(self.purchasesDelegate.makeDeferredPurchase).toEventuallyNot(beNil()) + expect(self.purchasesDelegate.makeDeferredPurchase).toNot(beNil()) + + expect(self.purchasesDelegate.promoProduct) == StoreProduct(sk1Product: self.product) + expect(self.purchasesDelegate.makeDeferredPurchase).toNot(beNil()) } }