From ce4f0d11d7ec50a5868c6214760f15a6cc93904a Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 10 Dec 2024 16:52:44 +0100 Subject: [PATCH] Fixes and improvements --- PadelClub/Data/DataStore.swift | 12 ++++++------ PadelClub/Data/PlayerRegistration.swift | 9 ++++++--- PadelClub/Data/TeamScore.swift | 11 ++++++++--- PadelClub/Utils/URLs.swift | 2 +- .../Views/Navigation/Toolbox/DebugSettingsView.swift | 6 +++--- PadelClub/Views/User/ShareModelView.swift | 2 +- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/PadelClub/Data/DataStore.swift b/PadelClub/Data/DataStore.swift index dc5b308..b2afec5 100644 --- a/PadelClub/Data/DataStore.swift +++ b/PadelClub/Data/DataStore.swift @@ -54,18 +54,18 @@ class DataStore: ObservableObject { let store = Store.main StoreCenter.main.blackListUserName("apple-test") - let httpScheme: String = URLs.httpScheme.rawValue +// let secureScheme = true let domain: String = URLs.activationHost.rawValue #if DEBUG - if let scheme = PListReader.readString(plist: "local", key: "server_scheme"), - let domain = PListReader.readString(plist: "local", key: "server_domain"){ - StoreCenter.main.configureURLs(httpScheme: scheme, domain: domain) + if let secure = PListReader.readBool(plist: "local", key: "secure_server"), + let domain = PListReader.readString(plist: "local", key: "server_domain") { + StoreCenter.main.configureURLs(secureScheme: secure, domain: domain) } else { - StoreCenter.main.configureURLs(httpScheme: httpScheme, domain: domain) + StoreCenter.main.configureURLs(secureScheme: true, domain: domain) } #else - StoreCenter.main.configureURLs(httpScheme: httpScheme, domain: domain) + StoreCenter.main.configureURLs(secureScheme: true, domain: domain) #endif StoreCenter.main.logsFailedAPICalls() diff --git a/PadelClub/Data/PlayerRegistration.swift b/PadelClub/Data/PlayerRegistration.swift index f6ef828..003024f 100644 --- a/PadelClub/Data/PlayerRegistration.swift +++ b/PadelClub/Data/PlayerRegistration.swift @@ -125,10 +125,13 @@ final class PlayerRegistration: BasePlayerRegistration, SideStorable { } var tournamentStore: TournamentStore { - if let store = self.store as? TournamentStore { - return store + guard let storeId else { + fatalError("missing store id for \(String(describing: type(of: self)))") } - fatalError("missing store for \(String(describing: type(of: self)))") + return TournamentLibrary.shared.store(tournamentId: storeId) +// if let store = self.store as? TournamentStore { +// return store +// } } var computedAge: Int? { diff --git a/PadelClub/Data/TeamScore.swift b/PadelClub/Data/TeamScore.swift index 945191f..c3fedde 100644 --- a/PadelClub/Data/TeamScore.swift +++ b/PadelClub/Data/TeamScore.swift @@ -51,10 +51,15 @@ final class TeamScore: BaseTeamScore, SideStorable { } var tournamentStore: TournamentStore { - if let store = self.store as? TournamentStore { - return store + guard let storeId else { + fatalError("missing store id for \(String(describing: type(of: self)))") } - fatalError("missing store for \(String(describing: type(of: self)))") + return TournamentLibrary.shared.store(tournamentId: storeId) +// +// if let store = self.store as? TournamentStore { +// return store +// } +// fatalError("missing store for \(String(describing: type(of: self)))") } // MARK: - Computed dependencies diff --git a/PadelClub/Utils/URLs.swift b/PadelClub/Utils/URLs.swift index 777e77a..d7d0222 100644 --- a/PadelClub/Utils/URLs.swift +++ b/PadelClub/Utils/URLs.swift @@ -8,7 +8,7 @@ import Foundation enum URLs: String, Identifiable { - case httpScheme = "https://" +// case httpScheme = "https://" #if DEBUG case activationHost = "xlr.alwaysdata.net" case main = "https://xlr.alwaysdata.net/" diff --git a/PadelClub/Views/Navigation/Toolbox/DebugSettingsView.swift b/PadelClub/Views/Navigation/Toolbox/DebugSettingsView.swift index 84786f0..f2f7943 100644 --- a/PadelClub/Views/Navigation/Toolbox/DebugSettingsView.swift +++ b/PadelClub/Views/Navigation/Toolbox/DebugSettingsView.swift @@ -14,7 +14,7 @@ struct DebugSettingsView: View { LabeledContent("UUID", value: self._userId) LabeledContent("User Name", value: self._userName) LabeledContent("Token", value: self._token) - LabeledContent("Server", value: self._server) + LabeledContent("Server", value: self._apiURL) LabeledContent("Synchronized", value: self._synchronized) LabeledContent("CollectionsCanSynchronize", value: self._canSynchronize) } @@ -32,8 +32,8 @@ struct DebugSettingsView: View { return StoreCenter.main.token() ?? "" } - fileprivate var _server: String { - return PListReader.readString(plist: "local", key: "server") ?? "" + fileprivate var _apiURL: String { + return StoreCenter.main.apiURL ?? "not configured" } fileprivate var _synchronized: String { diff --git a/PadelClub/Views/User/ShareModelView.swift b/PadelClub/Views/User/ShareModelView.swift index 90c6a45..c281ccd 100644 --- a/PadelClub/Views/User/ShareModelView.swift +++ b/PadelClub/Views/User/ShareModelView.swift @@ -70,7 +70,7 @@ struct ShareModelView : View { .listStyle(PlainListStyle()) .navigationTitle("Partage") } else { - ContentUnavailableView("Si vous souhaitez partager votre tournoi avec d'autres utilisateurs, veuillez contacter notre support", image: "person.fill.xmark") + ContentUnavailableView("Si vous souhaitez partager votre tournoi avec d'autres utilisateurs, veuillez contacter notre support", image: "person.crop.circle.badge.xmark") } }.onAppear {