@@ -17,14 +17,16 @@ import SwiftyJSON
1717public actor CurrentUserManager {
1818 let logger = Logger ( subsystem: " com.beeminder.beeminder " , category: " CurrentUserManager " )
1919
20- public static let signedInNotificationName = " com.beeminder.signedInNotification "
21- public static let willSignOutNotificationName = " com.beeminder.willSignOutNotification "
22- public static let failedSignInNotificationName = " com.beeminder.failedSignInNotification "
23- public static let signedOutNotificationName = " com.beeminder.signedOutNotification "
24- public static let resetNotificationName = " com.beeminder.resetNotification "
25- public static let willResetNotificationName = " com.beeminder.willResetNotification "
26- public static let healthKitMetricRemovedNotificationName = " com.beeminder.healthKitMetricRemovedNotification "
27-
20+ public enum NotificationName {
21+ public static let signedIn = NSNotification . Name ( rawValue: " com.beeminder.signedInNotification " )
22+ public static let willSignOut = NSNotification . Name ( rawValue: " com.beeminder.willSignOutNotification " )
23+ public static let failedSignIn = NSNotification . Name ( rawValue: " com.beeminder.failedSignInNotification " )
24+ public static let signedOut = NSNotification . Name ( rawValue: " com.beeminder.signedOutNotification " )
25+ public static let reset = NSNotification . Name ( rawValue: " com.beeminder.resetNotification " )
26+ public static let willReset = NSNotification . Name ( rawValue: " com.beeminder.willResetNotification " )
27+ public static let healthKitMetricRemoved = NSNotification . Name ( rawValue: " com.beeminder.healthKitMetricRemovedNotification " )
28+ }
29+
2830 fileprivate let beemiosSecret = " C0QBFPWqDykIgE6RyQ2OJJDxGxGXuVA2CNqcJM185oOOl4EQTjmpiKgcwjki "
2931
3032 internal static let accessTokenKey = " access_token "
@@ -165,28 +167,28 @@ public actor CurrentUserManager {
165167 self . setAccessToken ( responseJSON [ CurrentUserManager . accessTokenKey] . string!)
166168
167169 await Task { @MainActor in
168- NotificationCenter . default. post ( name: Notification . Name ( rawValue : CurrentUserManager . signedInNotificationName ) , object: self )
170+ NotificationCenter . default. post ( name: CurrentUserManager . NotificationName . signedIn , object: self )
169171 } . value
170172 }
171173
172174 func handleFailedSignin( _ responseError: Error , errorMessage : String ? ) async throws {
173175 await Task { @MainActor in
174- NotificationCenter . default. post ( name: Notification . Name ( rawValue : CurrentUserManager . failedSignInNotificationName ) , object: self , userInfo: [ " error " : responseError] )
176+ NotificationCenter . default. post ( name: CurrentUserManager . NotificationName . failedSignIn , object: self , userInfo: [ " error " : responseError] )
175177 } . value
176178 try await self . signOut ( )
177179 }
178180
179181 public func signOut( ) async throws {
180182 await Task { @MainActor in
181- NotificationCenter . default. post ( name: Notification . Name ( rawValue : CurrentUserManager . willSignOutNotificationName ) , object: self )
183+ NotificationCenter . default. post ( name: CurrentUserManager . NotificationName . willSignOut , object: self )
182184 } . value
183185
184186 try deleteUser ( )
185187
186188 keychain. delete ( CurrentUserManager . accessTokenKey)
187189
188190 await Task { @MainActor in
189- NotificationCenter . default. post ( name: Notification . Name ( rawValue : CurrentUserManager . signedOutNotificationName ) , object: self )
191+ NotificationCenter . default. post ( name: CurrentUserManager . NotificationName . signedOut , object: self )
190192 } . value
191193 }
192- }
194+ }
0 commit comments