adds a way to see product ids in the interface

release
Laurent 1 year ago
parent c9b812cd7e
commit 7d4ccf0f67
  1. 2
      PadelClub.xcodeproj/xcshareddata/xcschemes/PadelClub.xcscheme
  2. 40
      PadelClub/Views/Navigation/Umpire/UmpireView.swift
  3. 24
      PadelClub/Views/Tournament/Subscription/Guard.swift

@ -74,7 +74,7 @@
</BuildableReference>
</BuildableProductRunnable>
<StoreKitConfigurationFileReference
identifier = "../../PadelClub/SyncedProducts.storekit">
identifier = "../PadelClub/SyncedProducts.storekit">
</StoreKitConfigurationFileReference>
</LaunchAction>
<ProfileAction

@ -16,6 +16,7 @@ struct UmpireView: View {
@State private var presentSearchView: Bool = false
@State private var showSubscriptions: Bool = false
@State private var showProductIds: Bool = false
// @State var isConnected: Bool = false
@ -36,7 +37,20 @@ struct UmpireView: View {
self.showSubscriptions = true
} label: {
Label("Les offres", systemImage: "bookmark.fill")
}
}.simultaneousGesture(
LongPressGesture()
.onEnded { _ in
self.showProductIds = true
}
)
.highPriorityGesture(
TapGesture()
.onEnded { _ in
self.showSubscriptions = true
}
)
}
}
@ -161,6 +175,9 @@ struct UmpireView: View {
.environment(\.colorScheme, .light)
}
})
.sheet(isPresented: self.$showProductIds, content: {
ProductIdsView()
})
.sheet(isPresented: $presentSearchView) {
let user = dataStore.user
NavigationStack {
@ -228,6 +245,27 @@ struct AccountRowView: View {
}
}
struct ProductIdsView: View {
@State var ids: [String] = []
var body: some View {
VStack {
List {
LabeledContent("count", value: String(ids.count))
ForEach(self.ids) { id in
Text(id)
}
}.onAppear {
Task {
self.ids = await Guard.main.productIds()
}
}
}
}
}
//#Preview {
// UmpireView()
//}

@ -18,7 +18,7 @@ import LeStorage
var currentBestPlan: StoreKit.Transaction? = nil
var updateListenerTask: Task<Void, Error>? = nil
var updateListenerTask: Task<Void, Never>? = nil
fileprivate(set) var purchases: StoredCollection<Purchase>
@ -39,6 +39,23 @@ import LeStorage
}
}
deinit {
self.updateListenerTask?.cancel()
}
func productIds() async -> [String] {
var productIds: [String] = []
for await result in Transaction.all {
do {
let verified = try self.checkVerified(result)
productIds.append(verified.productID)
} catch {
Logger.error(error)
}
}
return productIds
}
func refreshPurchasedAppleProducts() async throws {
// Iterate through the user's purchased products.
@ -51,10 +68,11 @@ import LeStorage
}
}
func listenForTransactions() -> Task<Void, Error> {
return Task.detached {
func listenForTransactions() -> Task<Void, Never> {
return Task(priority: .background) {
//Iterate through any transactions which didn't come from a direct call to `purchase()`.
for await result in Transaction.updates {
Logger.log(">>> update = \(result)")
do {
let transaction = try self.checkVerified(result)

Loading…
Cancel
Save