LOOP-1628: fix ordering & update guardrail correctly#18
Conversation
|
|
||
| init(model: TherapySettingsViewModel){ | ||
| precondition(model.therapySettings.glucoseUnit != nil) | ||
| precondition(model.therapySettings.glucoseTargetRangeSchedule?.scheduleRange() != nil) |
There was a problem hiding this comment.
[nit] can simplify the precondition to being on the optionality of glucoseTargetRangeSchedule itself, since scheduleRange()'s return value is non-optional
| maxValue: [ | ||
| viewModel.therapySettings.glucoseTargetRangeSchedule?.minLowerBound().doubleValue(for: unit), | ||
| viewModel.therapySettings.preMealTargetRange?.minValue, | ||
| viewModel.therapySettings.workoutTargetRange?.minValue | ||
| ] | ||
| .compactMap { $0 } | ||
| .min() | ||
| .map { HKQuantity(unit: unit, doubleValue: $0) }, |
There was a problem hiding this comment.
I wonder if it's worth extracting this logic to LoopKit so it can be shared with Loop (since the concept of suspend threshold now exists in LoopKit anyway)
I'm not sure where it would live.. maybe just a static function on Guardrail?
extension Guardrail where Value == HKQuantity {
static func maxSuspendThresholdValue(correctionRangeSchedule: GlucoseRangeSchedule, preMealTargetRange: DoubleRange, workoutTargetRange: DoubleRange)
}WDYT?
There was a problem hiding this comment.
That makes sense so we're not duplicating it in multiple places
rickpasetto
left a comment
There was a problem hiding this comment.
Some comments for consideration, but other than that LGTM
| } | ||
| let view = CorrectionRangeInformationView(onExit: onExit) | ||
| let hostedView = DismissibleHostingController(rootView: view) | ||
| hostedView.navigationItem.largeTitleDisplayMode = .always // TODO: hack to fix jumping, will be removed once editors have titles |
There was a problem hiding this comment.
Interesting find! I will try using this on my own screens, as I'm seeing that jumping, too.
| } | ||
| settingsViewModel.didFinishStep = didFinishStep | ||
|
|
||
| screenStack = [.enterCode] |
There was a problem hiding this comment.
Is this always supposed to be first now?
There was a problem hiding this comment.
Yes, from the discussions with design/product it seems that the therapy settings flow will be restarted from the beginning if the app quits
https://tidepool.atlassian.net/browse/LOOP-1628