From b7f2b338167427b1762ebef77cc9fc83343207ea Mon Sep 17 00:00:00 2001 From: Raz Date: Fri, 25 Oct 2024 15:18:03 +0200 Subject: [PATCH] fix issue with match deletion in groupstage --- PadelClub/Data/GroupStage.swift | 1 + .../Views/GroupStage/Components/GroupStageSettingsView.swift | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/PadelClub/Data/GroupStage.swift b/PadelClub/Data/GroupStage.swift index 7b21f1b..da476cb 100644 --- a/PadelClub/Data/GroupStage.swift +++ b/PadelClub/Data/GroupStage.swift @@ -146,6 +146,7 @@ final class GroupStage: ModelObject, Storable { func buildMatches(keepExistingMatches: Bool = false) { var teamScores = [TeamScore]() var matches = [Match]() + clearScoreCache() if keepExistingMatches == false { _removeMatches() diff --git a/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift b/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift index 7bf706d..5bfa715 100644 --- a/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift +++ b/PadelClub/Views/GroupStage/Components/GroupStageSettingsView.swift @@ -143,7 +143,11 @@ struct GroupStageSettingsView: View { Section { RowButtonView("Recommencer tous les matchs", role: .destructive) { + let isReturnMatchesEnabled = groupStage.isReturnMatchEnabled() groupStage.buildMatches() + if isReturnMatchesEnabled { + groupStage.addReturnMatches() + } } } footer: { Text("Tous les matchs seront recronstruits, les données des matchs seront perdus.")