fix ongoing

main
Razmig Sarkissian 2 weeks ago
parent a16897f3ed
commit d9657ace50
  1. 17
      PadelClub/Views/Navigation/Ongoing/OngoingContainerView.swift

@ -16,11 +16,7 @@ class OngoingViewModel {
var destination: OngoingDestination? = .running var destination: OngoingDestination? = .running
var hideUnconfirmedMatches: Bool = false var hideUnconfirmedMatches: Bool = false
var hideNotReadyMatches: Bool = false var hideNotReadyMatches: Bool = false
var selectedTournaments: Set<String> = Set() { var selectedTournaments: Set<String> = Set()
didSet {
DataStore.shared.resetOngoingCache()
}
}
func tournaments() -> [Tournament] { func tournaments() -> [Tournament] {
Set(DataStore.shared.runningAndNextMatches().compactMap({ $0.currentTournament() })).sorted(by: \.startDate) Set(DataStore.shared.runningAndNextMatches().compactMap({ $0.currentTournament() })).sorted(by: \.startDate)
@ -75,20 +71,23 @@ struct OngoingContainerView: View {
.tag(tournament.id) .tag(tournament.id)
} }
} }
.onChange(of: ongoingViewModel.selectedTournaments, { oldValue, newValue in
DataStore.shared.resetOngoingCache()
})
.environment(\.editMode, Binding.constant(EditMode.active)) .environment(\.editMode, Binding.constant(EditMode.active))
.navigationTitle("Tournois visibles") .navigationTitle("Tournois à masquer")
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar)
} label: { } label: {
Label("Tournois visibles", systemImage: "circle.grid.2x2.topleft.checkmark.filled") Label("Masquer des tournois", systemImage: "circle.grid.2x2.topleft.checkmark.filled")
} }
if ongoingViewModel.destination == .followUp { if ongoingViewModel.destination == .followUp {
Divider() Divider()
Toggle(isOn: $ongoingViewModel.hideUnconfirmedMatches) { Toggle(isOn: $ongoingViewModel.hideUnconfirmedMatches) {
Text("masquer non confirmés") Text("Masquer non confirmés")
} }
Toggle(isOn: $ongoingViewModel.hideNotReadyMatches) { Toggle(isOn: $ongoingViewModel.hideNotReadyMatches) {
Text("masquer incomplets") Text("Masquer incomplets")
} }
} }
} label: { } label: {

Loading…
Cancel
Save