fix issue with remove all seeds

sync2
Raz 9 months ago
parent 86b3af8337
commit 715c1b69e0
  1. 29
      PadelClub/Data/Tournament.swift

@ -2415,27 +2415,42 @@ defer {
}
func removeAllSeeds() async {
unsortedTeams().forEach({ team in
let teams = unsortedTeams()
teams.forEach({ team in
team.bracketPosition = nil
team._cachedRestingTime = nil
})
let ts = allRoundMatches().flatMap { match in
let allMatches = allRoundMatches()
let ts = allMatches.flatMap { match in
match.teamScores
}
allMatches.forEach { match in
match.disabled = false
match.losingTeamId = nil
match.winningTeamId = nil
match.endDate = nil
match.removeCourt()
match.servingTeamId = nil
}
do {
try tournamentStore.teamScores.delete(contentOfs: ts)
} catch {
Logger.error(error)
}
do {
try tournamentStore.teamRegistrations.addOrUpdate(contentOfs: unsortedTeams())
try tournamentStore.matches.addOrUpdate(contentOfs: allMatches)
} catch {
Logger.error(error)
}
allRounds().forEach({ round in
round.enableRound()
})
do {
try tournamentStore.teamRegistrations.addOrUpdate(contentOfs: teams)
} catch {
Logger.error(error)
}
updateTournamentState()
}
func addNewRound(_ roundIndex: Int) async {

Loading…
Cancel
Save