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

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

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

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

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

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

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

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

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

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

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

@ -141,7 +141,7 @@ import LeStorage
var currentPlan: StoreItem? { var currentPlan: StoreItem? {
return .monthlyUnlimited return .monthlyUnlimited
// #if _DEBUG_OPTIONS // #if DEBUG
// return .monthlyUnlimited // return .monthlyUnlimited
// #else // #else
if let currentBestPlan = self.currentBestPlan, let plan = StoreItem(rawValue: currentBestPlan.productID) { 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 fivePerMonth = "app.padelclub.tournament.subscription.five.per.month"
case unit = "app.padelclub.tournament.unit" case unit = "app.padelclub.tournament.unit"
#if _DEBUG_OPTIONS #if DEBUG
static let five: Int = 2 static let five: Int = 2
#else #else
static let five: Int = 5 static let five: Int = 5

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

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

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

Loading…
Cancel
Save