diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index a9d7428..85e8fa6 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3879,7 +3879,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 4; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -3922,7 +3922,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 4; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/AppDelegate.swift b/PadelClub/AppDelegate.swift index c57e143..a678151 100644 --- a/PadelClub/AppDelegate.swift +++ b/PadelClub/AppDelegate.swift @@ -27,7 +27,7 @@ class AppDelegate : NSObject, UIApplicationDelegate, UNUserNotificationCenterDel func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { - if StoreCenter.main.hasToken() { + if StoreCenter.main.isAuthenticated { Task { do { let services = try StoreCenter.main.service() diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index a576d5e..07feb15 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -2320,7 +2320,7 @@ defer { } func refreshTeamList() async { - guard StoreCenter.main.hasToken() else { return } + guard StoreCenter.main.isAuthenticated else { return } guard shouldRefreshTeams(), refreshInProgress == false, enableOnlineRegistration, hasEnded() == false else { return } await MainActor.run { refreshInProgress = true diff --git a/PadelClub/Views/Navigation/MainView.swift b/PadelClub/Views/Navigation/MainView.swift index c92b57e..b306c5c 100644 --- a/PadelClub/Views/Navigation/MainView.swift +++ b/PadelClub/Views/Navigation/MainView.swift @@ -47,12 +47,8 @@ struct MainView: View { } )} - private func _isConnected() -> Bool { - return StoreCenter.main.hasToken() && StoreCenter.main.userId != nil - } - var badgeText: Text? { - return (dataStore.appSettings.didCreateAccount && _isConnected() == false) ? Text("!").font(.headline) : nil + return (dataStore.appSettings.didCreateAccount && StoreCenter.main.isAuthenticated == false) ? Text("!").font(.headline) : nil } var body: some View { @@ -105,7 +101,7 @@ struct MainView: View { .environmentObject(dataStore) .task { //await self._checkSourceFileAvailability() - if StoreCenter.main.hasToken() { + if StoreCenter.main.isAuthenticated { do { try await dataStore.clubs.loadDataFromServerIfAllowed() } catch { diff --git a/PadelClub/Views/Navigation/Umpire/UmpireView.swift b/PadelClub/Views/Navigation/Umpire/UmpireView.swift index d72ba88..872be35 100644 --- a/PadelClub/Views/Navigation/Umpire/UmpireView.swift +++ b/PadelClub/Views/Navigation/Umpire/UmpireView.swift @@ -55,7 +55,7 @@ struct UmpireView: View { } } - if self._isConnected() { + if StoreCenter.main.isAuthenticated { NavigationLink { AccountView(user: dataStore.user) { } } label: { @@ -242,10 +242,6 @@ struct UmpireView: View { } } - fileprivate func _isConnected() -> Bool { - return dataStore.user.username.count > 0 && StoreCenter.main.hasToken() - } - } struct AccountRowView: View { @@ -254,9 +250,9 @@ struct AccountRowView: View { var userName: String var body: some View { - let hasToken = StoreCenter.main.hasToken() + let isAuthenticated = StoreCenter.main.isAuthenticated LabeledContent { - if hasToken { + if isAuthenticated { Text(self.userName) } else if StoreCenter.main.userName() != nil { Image(systemName: "xmark.circle.fill") @@ -264,7 +260,7 @@ struct AccountRowView: View { } } label: { Label("Mon compte", systemImage: "person.fill") - if hasToken && dataStore.user.email.isEmpty == false { + if isAuthenticated && dataStore.user.email.isEmpty == false { Text(dataStore.user.email) } }