Make server purchase active

paca_championship
Laurent 1 year ago
parent f174ccfe57
commit 7811806925
  1. 4
      PadelClub/Data/DataStore.swift
  2. 11
      PadelClub/Views/Tournament/Subscription/Guard.swift
  3. 5
      PadelClub/Views/User/AccountView.swift

@ -101,6 +101,10 @@ class DataStore: ObservableObject {
} }
deinit {
NotificationCenter.default.removeObserver(self)
}
func saveUser() { func saveUser() {
do { do {
if user.username.count > 0 { if user.username.count > 0 {

@ -20,7 +20,6 @@ import LeStorage
var updateListenerTask: Task<Void, Never>? = nil var updateListenerTask: Task<Void, Never>? = nil
override init() { override init() {
super.init() super.init()
@ -34,10 +33,20 @@ import LeStorage
Logger.error(error) Logger.error(error)
} }
} }
NotificationCenter.default.addObserver(self, selector: #selector(collectionDidLoad), name: NSNotification.Name.CollectionDidLoad, object: nil)
} }
deinit { deinit {
self.updateListenerTask?.cancel() self.updateListenerTask?.cancel()
NotificationCenter.default.removeObserver(self)
}
@objc func collectionDidLoad(notification: Notification) {
if let _ = notification.object as? StoredCollection<Purchase> {
self._updateBestPlan()
}
} }
func productIds() async -> [String] { func productIds() async -> [String] {

@ -15,6 +15,11 @@ struct AccountView: View {
var body: some View { var body: some View {
Form { Form {
#if DEBUG
if let purchase = Guard.main.currentBestPurchase, let item = StoreItem(rawValue: purchase.productId) {
PurchaseView(purchaseRow: PurchaseRow(id: purchase.id, name: purchase.productId, item: item))
}
#endif
Section { Section {
NavigationLink("Changer de mot de passe") { NavigationLink("Changer de mot de passe") {
ChangePasswordView() ChangePasswordView()

Loading…
Cancel
Save