|
|
|
|
@ -338,30 +338,36 @@ struct RoundView: View { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//todo should be done server side |
|
|
|
|
let rounds = tournament.rounds() |
|
|
|
|
rounds.forEach { round in |
|
|
|
|
let matches = round.playedMatches() |
|
|
|
|
matches.forEach { match in |
|
|
|
|
match.name = Match.setServerTitle(upperRound: round, matchIndex: match.indexInRound(in: matches)) |
|
|
|
|
} |
|
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let loserMatches = self.upperRound.loserMatches() |
|
|
|
|
loserMatches.forEach { match in |
|
|
|
|
match.name = match.roundTitle() |
|
|
|
|
} |
|
|
|
|
_refreshNames() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let allRoundMatches = tournament.allRoundMatches() |
|
|
|
|
private func _refreshNames() { |
|
|
|
|
DispatchQueue.global(qos: .background).async { |
|
|
|
|
//todo should be done server side |
|
|
|
|
let rounds = tournament.rounds() |
|
|
|
|
rounds.forEach { round in |
|
|
|
|
let matches = round.playedMatches() |
|
|
|
|
matches.forEach { match in |
|
|
|
|
match.name = Match.setServerTitle(upperRound: round, matchIndex: match.indexInRound(in: matches)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
try tournament.tournamentStore.matches.addOrUpdate(contentOfs: allRoundMatches) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
let loserMatches = self.upperRound.loserMatches() |
|
|
|
|
loserMatches.forEach { match in |
|
|
|
|
match.name = match.roundTitle() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
let allRoundMatches = tournament.allRoundMatches() |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
try tournament.tournamentStore.matches.addOrUpdate(contentOfs: allRoundMatches) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|