From c25f94eed1cf971eebdf8803932ba600200a82eb Mon Sep 17 00:00:00 2001 From: Sean Goldin Date: Sun, 29 Jan 2023 00:37:23 -0600 Subject: [PATCH] Don't allow multiple tap on purchase button Close #393 --- .../App/Tabs/Settings/SupportAppView.swift | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/IceCubesApp/App/Tabs/Settings/SupportAppView.swift b/IceCubesApp/App/Tabs/Settings/SupportAppView.swift index adddccab..b2641614 100644 --- a/IceCubesApp/App/Tabs/Settings/SupportAppView.swift +++ b/IceCubesApp/App/Tabs/Settings/SupportAppView.swift @@ -97,15 +97,19 @@ struct SupportAppView: View { } Spacer() Button { - isProcessingPurchase = true - Task { - do { - _ = try await Purchases.shared.purchase(product: product) - purchaseSuccessDisplayed = true - } catch { - purchaseErrorDisplayed = true + if !isProcessingPurchase { + isProcessingPurchase = true + Task { + do { + let result = try await Purchases.shared.purchase(product: product) + if !result.userCancelled { + purchaseSuccessDisplayed = true + } + } catch { + purchaseErrorDisplayed = true + } + isProcessingPurchase = false } - isProcessingPurchase = false } } label: { if isProcessingPurchase {