-
Notifications
You must be signed in to change notification settings - Fork 8
nate/fix/LOOP-1927/manual-glucose-entry #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
rickpasetto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! (I can't wait until I write some unit tests for this 🤷 )
|
@ps2 I made a slight modification to the Also see tidepool-org/LoopKit#244 |
ps2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I have several suggestions in here, that I think would improve things, but none of them are critical.
|
|
||
| if view.bounds.width < 375 { | ||
| // need to adjust for narrow display | ||
| hudView.adjustViewsForNarrowDisplay = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the hud adjust its view itself if it's not given enough room? Adjust views depending on the size given would seem to be the view's responsibility, not a user of the view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overlooked this comment. Will do.
Loop/Models/ManualGlucoseState.swift
Outdated
| import Foundation | ||
| import LoopKit | ||
|
|
||
| struct ManualGlucoseState: SensorDisplayable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ManualGlucoseState -> ManualGlucoseDisplayable? And SensorDisplayable -> GlucoseDisplayable? The latter is LoopKit, I know, and maybe we do it later, but if this protocol is used to display both sensor and manual glucose data, the name could use updating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll definitely update GlucoseDisplayable now. I was confused when writing the code and happy to take this suggestion.
| func sensorState(for glucose: GlucoseSampleValue?) -> SensorDisplayable? { | ||
| if let glucose = glucose, glucose.wasUserEntered { | ||
| // the CGM manager needs to determine the glucoseValueType for a manual glucose based on its managed glucose thresholds | ||
| let glucoseValueType = (cgmManager as? CGMManagerUI)?.glucoseValueType(for: glucose) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably not right that we're asking the CGM to categorize the manual glucose value. It suggest that maybe glucose categorization should be a Loop concern. What do we do if we don't have a CGM? If this is too big, let's not tackle it here, but I think this is a sign we need to refactor glucose range categorization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ps2 The scenario when the CGM is not available was reported to design. They agree that ideally Loop manages the user glucose thresholds. However, they don't have a big concern with the style of the manually entered glucose being normal in the scenario when no CGM is setup. However, they would like to confirm there is no risk in a build at some point.
|
|
||
| var sensorState: SensorDisplayable? { | ||
| return cgmManager?.sensorState | ||
| func sensorState(for glucose: GlucoseSampleValue?) -> SensorDisplayable? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sensorState -> glucoseDisplay?
|
|
||
| glucoseValueTintColor = sensor?.glucoseValueType?.glucoseColor ?? .label | ||
| glucoseTrendTintColor = sensor?.glucoseValueType?.trendColor ?? .glucoseTintColor | ||
| glucoseTrendTintColor = isManualGlucose ? .destructive : sensor?.glucoseValueType?.trendColor ?? .glucoseTintColor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, when the sensor is in a warmup state, and the user enters a manual glucose value, there is not really any "error" that needs attending to. I guess this is a question for design/product. It seems like communicating the value as a manual entry is important, but painting it in error/warning colors when everything is operating as expected and user attention is not required is not great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that when the CGM is failing in some way, we don't want to paint over the failing state with a manual glucose entry that makes everything look ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ps2 yes, I'm working with Matt to determine all the possible states. Currently the known states include a red !, red or glucose colour +, and glucose colour <clock>, but we are still exploring.
|
@ps2 Ready for a formal review. With the naming update and the expanded use cases to consider how to display a manual glucose entry, this has become a much larger than expected PR. As for the logic when displaying a manual glucose entry, the value displays as expected, but the associated icon displays the current status highlight icon instead of a trend. If there is no status highlight (possible in development, but should never occur in prod), the icon displays |
rickpasetto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nits, but other than that LGTM 💭
|
|
||
| if view.bounds.width < 375 { | ||
| // need to adjust for narrow display | ||
| hudView.adjustViewsForNarrowDisplay = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
|
|
||
| var sensorState: SensorDisplayable? { | ||
| return cgmManager?.sensorState | ||
| func glucoseDisplay(for glucose: GlucoseSampleValue?) -> GlucoseDisplayable? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] this responsibility seems odd here in DeviceDataManager. I would have expected this to live in a ViewModel somewhere (maybe CGMStatusHUDViewModel?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's here because of the interaction with cgmManager. And the interaction with cgmManager is the not-great part, imo; we need to eventually make Loop be able to evaluate glucoseRangeCategories independently of a CGM; it's not right that the CGM is evaluating ranges for the fingerstick value. I think once we have resolved that, this can go somewhere that makes more sense.
ps2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; just have the one comment about making the view adjust itself rather than the client, which seems natural to me, but I won't hold this up for. And the other comment about glucose range thresholding not really belonging to the CGM, but that's probably best addressed later.
|
|
||
| var sensorState: SensorDisplayable? { | ||
| return cgmManager?.sensorState | ||
| func glucoseDisplay(for glucose: GlucoseSampleValue?) -> GlucoseDisplayable? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's here because of the interaction with cgmManager. And the interaction with cgmManager is the not-great part, imo; we need to eventually make Loop be able to evaluate glucoseRangeCategories independently of a CGM; it's not right that the CGM is evaluating ranges for the fingerstick value. I think once we have resolved that, this can go somewhere that makes more sense.
|
@ps2 I added the feature flag and switch for DIY to allow Loop to categorize the glucose range instead of the CGM Manager. |
ps2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I do think the (currently hardcoded) categorizer for DIY Loop should be used for both CGM and Fingerstick glucose values, but I can tackle this on the DIY side as well, later, if you want to get this in.
| return cgmManager?.sensorState | ||
| func glucoseDisplay(for glucose: GlucoseSampleValue?) -> GlucoseDisplayable? { | ||
| if let glucose = glucose, glucose.wasUserEntered { | ||
| guard FeatureFlags.cgmManagerCategorizeManualGlucoseRangeEnabled else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think categorization would differ based on manual/cgm values, so we should have one categorization routine for each. In this case, we are splitting between Tidepool Loop, which uses the Dexcom CGMManager categorization routine, and DIY Loop, which will use a hardcoded categorization routine for now. But eventually, they will use the same routine in Loop (which might coordinate with the CGMManager in some ways, but the settings and config will be in Loop).
In essence, I'm suggesting that this temporary hardcoded categorization be used for both cgm and fingerstick glucose values if the flag is turned on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know. I'll add this now.
https://tidepool.atlassian.net/browse/LOOP-1927
allow manual glucose entry without carb entry