Fix issue with tournamentStore loading after disconnect

club_update
Laurent 1 year ago
parent d9fd10a317
commit 6dfa2c8236
  1. 13
      PadelClub/Data/DataStore.swift
  2. 2
      PadelClub/Data/Tournament.swift
  3. 2
      PadelClub/Views/Calling/CallSettingsView.swift
  4. 2
      PadelClub/Views/Club/ClubsView.swift
  5. 2
      PadelClub/Views/GroupStage/GroupStagesSettingsView.swift
  6. 2
      PadelClub/Views/Navigation/Agenda/EventListView.swift
  7. 2
      PadelClub/Views/Navigation/Ongoing/OngoingView.swift
  8. 2
      PadelClub/Views/Navigation/Toolbox/ToolboxView.swift
  9. 2
      PadelClub/Views/Navigation/Umpire/UmpireView.swift
  10. 2
      PadelClub/Views/Round/RoundView.swift
  11. 2
      PadelClub/Views/Tournament/Screen/Components/TournamentStatusView.swift
  12. 2
      PadelClub/Views/Tournament/Subscription/Guard.swift
  13. 2
      PadelClub/Views/Tournament/Subscription/StoreItem.swift
  14. 2
      PadelClub/Views/Tournament/TournamentBuildView.swift
  15. 2
      PadelClub/Views/Tournament/TournamentView.swift
  16. 2
      PadelClub/Views/User/LoginView.swift

@ -54,7 +54,7 @@ class DataStore: ObservableObject {
let serverURL: String = URLs.api.rawValue
StoreCenter.main.blackListUserName("apple-test")
#if _DEBUG_OPTIONS
#if DEBUG
if let server = PListReader.readString(plist: "local", key: "server") {
StoreCenter.main.synchronizationApiURL = server
} else {
@ -70,7 +70,7 @@ class DataStore: ObservableObject {
_ = Guard.main // init
#if _DEBUG_OPTIONS
#if DEBUG
if let sync = PListReader.readBool(plist: "local", key: "synchronized") {
synchronized = sync
}
@ -172,14 +172,9 @@ class DataStore: ObservableObject {
}
}
StoreCenter.main.disconnect()
StoreCenter.main.collectionsCanSynchronize = false
for tournament in self.tournaments {
StoreCenter.main.destroyStore(identifier: tournament.id)
}
self.tournaments.reset()
self.clubs.reset()
self.courts.reset()
@ -187,6 +182,10 @@ class DataStore: ObservableObject {
self.dateIntervals.reset()
self.userStorage.reset()
for tournament in self.tournaments {
StoreCenter.main.destroyStore(identifier: tournament.id)
}
Guard.main.disconnect()
self.user = self._temporaryLocalUser.item ?? User.placeHolder()

@ -508,7 +508,7 @@ final class Tournament : ModelObject, Storable {
}
func courtUsed() -> [Int] {
#if _DEBUG_OPTIONS //DEBUGING TIME
#if DEBUG //DEBUGING TIME
let start = Date()
defer {
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000)

@ -56,7 +56,7 @@ struct CallSettingsView: View {
}
}
// #if _DEBUG_OPTIONS
// #if DEBUG
Section {
RowButtonView("Retirer toutes les convocations", role: .destructive) {
let teams = tournament.unsortedTeams()

@ -27,7 +27,7 @@ struct ClubsView: View {
var body: some View {
List {
#if _DEBUG_OPTIONS
#if DEBUG
Section {
RowButtonView("Delete unexisted clubs", action: {
let ids = dataStore.user.clubs

@ -73,7 +73,7 @@ struct GroupStagesSettingsView: View {
}
}
#if _DEBUG_OPTIONS
#if DEBUG
Section {
RowButtonView("delete all group stages") {
tournament.deleteGroupStages()

@ -112,7 +112,7 @@ struct EventListView: View {
}
}
}
#if _DEBUG_OPTIONS
#if DEBUG
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button(role: .destructive) {
do {

@ -44,7 +44,7 @@ struct OngoingView: View {
} footer: {
HStack {
Text(tournament.eventLabel())
#if _DEBUG_OPTIONS
#if DEBUG
Spacer()
FooterButtonView("copier l'id") {
let pasteboard = UIPasteboard.general

@ -49,7 +49,7 @@ struct ToolboxView: View {
}
#if _DEBUG_OPTIONS
#if DEBUG
Section {
NavigationLink("Settings") {

@ -145,7 +145,7 @@ struct UmpireView: View {
}
.navigationTitle("Juge-Arbitre")
.toolbar {
#if _DEBUG_OPTIONS
#if DEBUG
ToolbarItem(placement: .topBarTrailing) {
if StoreCenter.main.collectionsCanSynchronize {
Image(systemName: "checkmark.icloud")

@ -254,7 +254,7 @@ struct RoundView: View {
}
}
#if _DEBUG_OPTIONS
#if DEBUG
Spacer()
Text(match.teamScores.count.formatted())

@ -17,7 +17,7 @@ struct TournamentStatusView: View {
var body: some View {
Form {
#if _DEBUG_OPTIONS
#if DEBUG
RowButtonView("debug: Un-delete le tournoi") {
tournament.endDate = nil
tournament.isDeleted.toggle()

@ -141,7 +141,7 @@ import LeStorage
var currentPlan: StoreItem? {
return .monthlyUnlimited
// #if _DEBUG_OPTIONS
// #if DEBUG
// return .monthlyUnlimited
// #else
if let currentBestPlan = self.currentBestPlan, let plan = StoreItem(rawValue: currentBestPlan.productID) {

@ -12,7 +12,7 @@ enum StoreItem: String, Identifiable, CaseIterable {
case fivePerMonth = "app.padelclub.tournament.subscription.five.per.month"
case unit = "app.padelclub.tournament.unit"
#if _DEBUG_OPTIONS
#if DEBUG
static let five: Int = 2
#else
static let five: Int = 5

@ -92,7 +92,7 @@ struct TournamentBuildView: View {
Section {
#if _DEBUG_OPTIONS
#if DEBUG
NavigationLink(value: Screen.rankings) {
LabeledContent {
if tournament.publishRankings == false {

@ -154,7 +154,7 @@ struct TournamentView: View {
ToolbarItem(placement: .topBarTrailing) {
Menu {
#if _DEBUG_OPTIONS
#if DEBUG
Button {
do {
try self.tournament.payIfNecessary()

@ -180,7 +180,7 @@ struct LoginView: View {
}
.navigationTitle("Connexion")
.onAppear {
#if _DEBUG_OPTIONS
#if DEBUG
if let username = PListReader.readString(plist: "local", key: "username") {
self.username = username
}

Loading…
Cancel
Save