diff --git a/PadelClub/Views/Navigation/Agenda/EventListView.swift b/PadelClub/Views/Navigation/Agenda/EventListView.swift index 50e8b80..a3166f3 100644 --- a/PadelClub/Views/Navigation/Agenda/EventListView.swift +++ b/PadelClub/Views/Navigation/Agenda/EventListView.swift @@ -204,15 +204,15 @@ struct EventListView: View { } Divider() Menu { - Button { - Task { - await pcTournaments.concurrentForEach { tournament in - await tournament.refreshTeamList(forced: true) - } - } - } label: { - Text("M-à-j des inscriptions") - } +// Button { +// Task { +// await pcTournaments.concurrentForEach { tournament in +// await tournament.refreshTeamList(forced: true) +// } +// } +// } label: { +// Text("M-à-j des inscriptions") +// } Button { pcTournaments.forEach { tournament in @@ -413,27 +413,27 @@ struct EventListView: View { private func _tournamentView(_ tournament: Tournament) -> some View { NavigationLink(value: tournament) { TournamentCellView(tournament: tournament) - .onReceive(NotificationCenter.default.publisher(for: NSNotification.Name.CollectionDidLoad), perform: { notification in - - if let store = notification.object as? SyncedCollection { - if store.storeId == tournament.id { - if tournament.store?.fileCollectionsAllLoaded() == true { - tournament.lastTeamRefresh = nil - } - } - } - if let store = notification.object as? SyncedCollection { - if store.storeId == tournament.id { - if tournament.store?.fileCollectionsAllLoaded() == true { - tournament.lastTeamRefresh = nil - } - } - } - }) - .id(tournament.lastTeamRefresh) - .task(priority: .background) { - await tournament.refreshTeamList(forced: false) - } +// .onReceive(NotificationCenter.default.publisher(for: NSNotification.Name.CollectionDidLoad), perform: { notification in +// +// if let store = notification.object as? SyncedCollection { +// if store.storeId == tournament.id { +// if tournament.store?.fileCollectionsAllLoaded() == true { +// tournament.lastTeamRefresh = nil +// } +// } +// } +// if let store = notification.object as? SyncedCollection { +// if store.storeId == tournament.id { +// if tournament.store?.fileCollectionsAllLoaded() == true { +// tournament.lastTeamRefresh = nil +// } +// } +// } +// }) +// .id(tournament.lastTeamRefresh) +// .task(priority: .background) { +// await tournament.refreshTeamList(forced: false) +// } } .listRowView(isActive: tournament.enableOnlineRegistration, color: .green, hideColorVariation: true) .onChange(of: tournament.isTemplate) { diff --git a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift index 04a5981..b4fea9f 100644 --- a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift +++ b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift @@ -247,9 +247,9 @@ struct InscriptionManagerView: View { } if tournament.enableOnlineRegistration { - RowButtonView("Rafraîchir la liste", cornerRadius: 20) { - await _refreshList(forced: true) - } +// RowButtonView("Rafraîchir la liste", cornerRadius: 20) { +// await _refreshList(forced: true) +// } } else if tournament.onlineRegistrationCanBeEnabled() { RowButtonView("Inscription en ligne") { navigation.path.append(Screen.settings) @@ -261,12 +261,12 @@ struct InscriptionManagerView: View { } } } - .task(priority: .background) { - await _refreshList(forced: false) - } - .refreshable { - await _refreshList(forced: true) - } +// .task(priority: .background) { +// await _refreshList(forced: false) +// } +// .refreshable { +// await _refreshList(forced: true) +// } .onAppear { if tournament.enableOnlineRegistration == false || refreshStatus == true { _setHash(currentSelectedSortedTeams: selectedSortedTeams) @@ -581,31 +581,31 @@ struct InscriptionManagerView: View { // try? tournamentStore.playerRegistrations.addOrUpdate(contentOfs: players) // } // - private func _refreshList(forced: Bool) async { - if refreshStatus == true, forced == false { return } - if tournament.enableOnlineRegistration == false { return } - if tournament.hasEnded() { return } - if tournament.refreshInProgress { return } - - refreshResult = nil - refreshStatus = nil - do { - await self.tournament.refreshTeamList(forced: forced) - - _setHash() - if let lastTeamRefresh = self.tournament.lastTeamRefresh?.formatted(date: .abbreviated, time: .shortened) { - self.refreshResult = "Dernière m-à-j : \(lastTeamRefresh)" - } else { - self.refreshResult = "La synchronization a réussi" - } - self.refreshStatus = true - - } catch { - Logger.error(error) - self.refreshResult = "La synchronization a échoué" - self.refreshStatus = false - } - } +// private func _refreshList(forced: Bool) async { +// if refreshStatus == true, forced == false { return } +// if tournament.enableOnlineRegistration == false { return } +// if tournament.hasEnded() { return } +// if tournament.refreshInProgress { return } +// +// refreshResult = nil +// refreshStatus = nil +// do { +// await self.tournament.refreshTeamList(forced: forced) +// +// _setHash() +// if let lastTeamRefresh = self.tournament.lastTeamRefresh?.formatted(date: .abbreviated, time: .shortened) { +// self.refreshResult = "Dernière m-à-j : \(lastTeamRefresh)" +// } else { +// self.refreshResult = "La synchronization a réussi" +// } +// self.refreshStatus = true +// +// } catch { +// Logger.error(error) +// self.refreshResult = "La synchronization a échoué" +// self.refreshStatus = false +// } +// } private func _teamRegisteredView(selectedSortedTeams: [TeamRegistration]) -> some View { List { @@ -896,9 +896,9 @@ struct InscriptionManagerView: View { } } - RowButtonView("Rafraîchir les inscriptions en ligne") { - await _refreshList(forced: true) - } +// RowButtonView("Rafraîchir les inscriptions en ligne") { +// await _refreshList(forced: true) +// } } } header: { HStack {