diff --git a/PadelClub/Data/MatchScheduler.swift b/PadelClub/Data/MatchScheduler.swift index 869df0a..2f306c3 100644 --- a/PadelClub/Data/MatchScheduler.swift +++ b/PadelClub/Data/MatchScheduler.swift @@ -30,7 +30,7 @@ final class MatchScheduler : ModelObject, Storable { var shouldEndRoundBeforeStartingNext: Bool var groupStageChunkCount: Int? var overrideCourtsUnavailability: Bool = false - var shouldTryToFillUpCourtsAvailable: Bool = false + var shouldTryToFillUpCourtsAvailable: Bool = true var courtsAvailable: Set = Set() init(tournament: String, @@ -41,9 +41,12 @@ final class MatchScheduler : ModelObject, Storable { accountLoserBracketBreakTime: Bool = false, randomizeCourts: Bool = true, rotationDifferenceIsImportant: Bool = false, - shouldHandleUpperRoundSlice: Bool = true, + shouldHandleUpperRoundSlice: Bool = false, shouldEndRoundBeforeStartingNext: Bool = true, - groupStageChunkCount: Int? = nil, overrideCourtsUnavailability: Bool = false, shouldTryToFillUpCourtsAvailable: Bool = false, courtsAvailable: Set = Set()) { + groupStageChunkCount: Int? = nil, + overrideCourtsUnavailability: Bool = false, + shouldTryToFillUpCourtsAvailable: Bool = true, + courtsAvailable: Set = Set()) { self.tournament = tournament self.timeDifferenceLimit = timeDifferenceLimit self.loserBracketRotationDifference = loserBracketRotationDifference diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index e2e0a6f..a1feebc 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -800,13 +800,13 @@ defer { func selectedSortedTeams() -> [TeamRegistration] { - #if _DEBUG_TIME //DEBUGING TIME +// #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) print("func selectedSortedTeams", id, tournamentTitle(), duration.formatted(.units(allowed: [.seconds, .milliseconds]))) } - #endif +// #endif var _sortedTeams : [TeamRegistration] = [] var _teams = unsortedTeams().filter({ $0.walkOut == false }) @@ -1081,7 +1081,7 @@ defer { } } - func registrationIssues() -> Int { + func registrationIssues() async -> Int { let players : [PlayerRegistration] = unsortedPlayers() let selectedTeams : [TeamRegistration] = selectedSortedTeams() let callDateIssue : [TeamRegistration] = selectedTeams.filter { $0.callDate != nil && isStartDateIsDifferentThanCallDate($0) } diff --git a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift index 939be8a..1b724d7 100644 --- a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift +++ b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift @@ -48,6 +48,7 @@ struct InscriptionManagerView: View { @State private var presentAddTeamView: Bool = false @State private var compactMode: Bool = true @State private var pasteString: String? + @State private var registrationIssues: Int? = nil var tournamentStore: TournamentStore { return self.tournament.tournamentStore @@ -164,6 +165,9 @@ struct InscriptionManagerView: View { if self.teamsHash == nil, selectedSortedTeams.isEmpty == false { self.teamsHash = _simpleHash(ids: selectedSortedTeams.map { $0.id }) } + Task { + self.registrationIssues = await tournament.registrationIssues() + } } private func _handleHashDiff() { @@ -700,16 +704,19 @@ struct InscriptionManagerView: View { .fixedSize(horizontal: false, vertical: false) .listRowSeparator(.hidden) - let registrationIssues = tournament.registrationIssues() - if tournament.isAnimation() == false, registrationIssues > 0 { + if tournament.isAnimation() == false { NavigationLink { InscriptionInfoView() .environment(tournament) } label: { LabeledContent { - Text(tournament.registrationIssues().formatted()) - .foregroundStyle(.logoRed) - .fontWeight(.bold) + if let registrationIssues { + Text(registrationIssues.formatted()) + .foregroundStyle(.logoRed) + .fontWeight(.bold) + } else { + ProgressView() + } } label: { Text("Problèmes détectés") }