Skip to content

Commit

Permalink
Paywalls: present multiple concurrent purchases
Browse files Browse the repository at this point in the history
Tapping multiple times on the `PurchaseButton` can lead to "purchase already in progress", because of a race condition with SwiftUI not updating the `.disabled` state on time.
This works around that.
  • Loading branch information
NachoSoto committed Aug 9, 2023
1 parent 38b0ee3 commit 385037c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions RevenueCatUI/Views/PurchaseButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ struct PurchaseButton: View {

private var button: some View {
AsyncButton {
guard !self.purchaseHandler.actionInProgress else { return }

let cancelled = try await self.purchaseHandler.purchase(package: self.package,
with: self.mode).userCancelled

Expand Down

0 comments on commit 385037c

Please sign in to comment.