@@ -37,10 +37,6 @@ final class WatchDependenciesSynchronizer: NSObject, WCSessionDelegate {
3737 ///
3838 @Published var account : Account ?
3939
40- /// Tracks if the current watch session is active or not
41- ///
42- @Published private var isSessionActive : Bool = false
43-
4440 /// Toggle this value to force a credentials sync.
4541 ///
4642 @Published private var syncTrigger = false
@@ -99,15 +95,17 @@ final class WatchDependenciesSynchronizer: NSObject, WCSessionDelegate {
9995 . debounce ( for: 0.5 , scheduler: DispatchQueue . main)
10096
10197 // Syncs the dependencies to the paired counterpart when the session becomes available.
102- Publishers . CombineLatest3 ( watchDependencies , $isSessionActive , $syncTrigger)
103- . sink { [ weak self, watchSession] dependencies, isSessionActive , forceSync in
98+ watchDependencies . combineLatest ( $syncTrigger)
99+ . sink { [ weak self, watchSession] dependencies, forceSync in
104100
105101 // Do not update the context if the session is not active, the watch is not paired or the watch app is not installed.
106- guard isSessionActive, watchSession. isPaired, watchSession. isWatchAppInstalled else {
102+ guard watchSession. activationState == . activated,
103+ watchSession. isPaired,
104+ watchSession. isWatchAppInstalled else {
107105 self ? . analytics. track (
108106 . watchSyncingFailed,
109107 properties: [
110- " session_active " : isSessionActive ,
108+ " session_active " : watchSession . activationState == . activated ,
111109 " session_paired " : watchSession. isPaired,
112110 " watch_app_installed " : watchSession. isWatchAppInstalled
113111 ] ,
@@ -147,12 +145,6 @@ final class WatchDependenciesSynchronizer: NSObject, WCSessionDelegate {
147145
148146 func session( _ session: WCSession , activationDidCompleteWith activationState: WCSessionActivationState , error: Error ? ) {
149147 DDLogInfo ( " 🔵 WatchSession activated \( activationState) " )
150- analytics. track (
151- . watchActivationCompleted,
152- properties: [ " state " : activationState. rawValue] ,
153- error: error
154- )
155- self . isSessionActive = activationState == . activated
156148 }
157149
158150 func sessionDidBecomeInactive( _ session: WCSession ) {
@@ -161,7 +153,6 @@ final class WatchDependenciesSynchronizer: NSObject, WCSessionDelegate {
161153
162154 func sessionDidDeactivate( _ session: WCSession ) {
163155 // Try to guarantee an active session
164- self . isSessionActive = false
165156 watchSession. activate ( )
166157 }
167158}
@@ -201,10 +192,8 @@ extension WatchDependenciesSynchronizer {
201192
202193extension WatchDependenciesSynchronizer {
203194 enum SyncError : Error {
204- case missingStoreDetailsOrCredentials
205195 case watchSessionInactiveOrNotPaired
206196 case noDependenciesFound
207- case invalidApplicationContext
208197 case encodingApplicationContextFailed
209198 }
210199}
0 commit comments