Refactor hasToken with isAuthenticated

sync
Laurent 8 months ago
parent 8c5536c99b
commit e9aba1bd50
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 2
      PadelClub/AppDelegate.swift
  3. 2
      PadelClub/Data/Tournament.swift
  4. 8
      PadelClub/Views/Navigation/MainView.swift
  5. 12
      PadelClub/Views/Navigation/Umpire/UmpireView.swift

@ -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;

@ -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()

@ -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

@ -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 {

@ -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)
}
}

Loading…
Cancel
Save