@@ -83,8 +83,8 @@ public class SettingsViewModel: ObservableObject {
8383 @Published private( set) var automaticDosingStatus : AutomaticDosingStatus
8484
8585 @Published private( set) var lastLoopCompletion : Date ?
86- let mostRecentGlucoseDataDate : ( ) -> Date ?
87- let mostRecentPumpDataDate : ( ) -> Date ?
86+ @ Published private ( set ) var mostRecentGlucoseDataDate : Date ?
87+ @ Published private ( set ) var mostRecentPumpDataDate : Date ?
8888
8989 var closedLoopDescriptiveText : String ? {
9090 return delegate? . closedLoopDescriptiveText
@@ -116,9 +116,9 @@ public class SettingsViewModel: ObservableObject {
116116 let lastLoopCompletion = lastLoopCompletion ?? Date ( ) . addingTimeInterval ( . minutes( 16 ) )
117117 age = abs ( min ( 0 , lastLoopCompletion. timeIntervalSinceNow) )
118118 } else {
119- let mostRecentGlucoseDataDate = mostRecentGlucoseDataDate ( ) ?? Date ( ) . addingTimeInterval ( . minutes( 16 ) )
120- let mostRecentPumpDataDate = mostRecentPumpDataDate ( ) ?? Date ( ) . addingTimeInterval ( . minutes( 16 ) )
121- age = abs ( max ( min ( 0 , mostRecentGlucoseDataDate . timeIntervalSinceNow) , min ( 0 , mostRecentPumpDataDate . timeIntervalSinceNow) ) )
119+ let mostRecentGlucoseDataDate = mostRecentGlucoseDataDate ?? Date ( ) . addingTimeInterval ( . minutes( 16 ) )
120+ let mostRecentPumpDataDate = mostRecentPumpDataDate ?? Date ( ) . addingTimeInterval ( . minutes( 16 ) )
121+ age = max ( abs ( min ( 0 , mostRecentPumpDataDate . timeIntervalSinceNow) ) , abs ( min ( 0 , mostRecentGlucoseDataDate . timeIntervalSinceNow) ) )
122122 }
123123
124124 return LoopCompletionFreshness ( age: age)
@@ -139,8 +139,8 @@ public class SettingsViewModel: ObservableObject {
139139 automaticDosingStatus: AutomaticDosingStatus ,
140140 automaticDosingStrategy: AutomaticDosingStrategy ,
141141 lastLoopCompletion: Published < Date ? > . Publisher ,
142- mostRecentGlucoseDataDate: @escaping ( ) -> Date ? ,
143- mostRecentPumpDataDate: @escaping ( ) -> Date ? ,
142+ mostRecentGlucoseDataDate: Published < Date ? > . Publisher ,
143+ mostRecentPumpDataDate: Published < Date ? > . Publisher ,
144144 availableSupports: [ SupportUI ] ,
145145 isOnboardingComplete: Bool ,
146146 therapySettingsViewModelDelegate: TherapySettingsViewModelDelegate ? ,
@@ -159,8 +159,8 @@ public class SettingsViewModel: ObservableObject {
159159 self . automaticDosingStatus = automaticDosingStatus
160160 self . automaticDosingStrategy = automaticDosingStrategy
161161 self . lastLoopCompletion = nil
162- self . mostRecentGlucoseDataDate = mostRecentGlucoseDataDate
163- self . mostRecentPumpDataDate = mostRecentPumpDataDate
162+ self . mostRecentGlucoseDataDate = nil
163+ self . mostRecentPumpDataDate = nil
164164 self . availableSupports = availableSupports
165165 self . isOnboardingComplete = isOnboardingComplete
166166 self . therapySettingsViewModelDelegate = therapySettingsViewModelDelegate
@@ -190,7 +190,12 @@ public class SettingsViewModel: ObservableObject {
190190 lastLoopCompletion
191191 . assign ( to: \. lastLoopCompletion, on: self )
192192 . store ( in: & cancellables)
193-
193+ mostRecentGlucoseDataDate
194+ . assign ( to: \. mostRecentGlucoseDataDate, on: self )
195+ . store ( in: & cancellables)
196+ mostRecentPumpDataDate
197+ . assign ( to: \. mostRecentPumpDataDate, on: self )
198+ . store ( in: & cancellables)
194199 }
195200}
196201
@@ -215,8 +220,8 @@ extension SettingsViewModel {
215220 automaticDosingStatus: AutomaticDosingStatus ( automaticDosingEnabled: true , isAutomaticDosingAllowed: true ) ,
216221 automaticDosingStrategy: . automaticBolus,
217222 lastLoopCompletion: FakeLastLoopCompletionPublisher ( ) . $mockLastLoopCompletion,
218- mostRecentGlucoseDataDate: { nil } ,
219- mostRecentPumpDataDate: { nil } ,
223+ mostRecentGlucoseDataDate: FakeLastLoopCompletionPublisher ( ) . $mockLastLoopCompletion ,
224+ mostRecentPumpDataDate: FakeLastLoopCompletionPublisher ( ) . $mockLastLoopCompletion ,
220225 availableSupports: [ ] ,
221226 isOnboardingComplete: false ,
222227 therapySettingsViewModelDelegate: nil ,
0 commit comments