-
Notifications
You must be signed in to change notification settings - Fork 514
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
Added ability to add min and max values to decimals in preferences page #232
Conversation
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!
FreeAPS/Sources/Modules/PreferencesEditor/PreferencesEditorStateModel.swift
Outdated
Show resolved
Hide resolved
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
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.
Besides the remainingCarbsCap min value of 90 g, LGTM.
When testing entering a value below the 90 g min limit for remainingCarbsCap, the value is immediately changed to 90 g when tapping Done
. There is no feedback otherwise, but that may not be needed. The important part is being able to disallow invalid settings, while still showing what setting is being used.
fcfd751
Oh yeah, I also meant to test or ask about what happens when someone already set something outside of the guardrails before the guardrail was added. Will it just silently reset it within the guardrails the next time the preference menu is open? We should also at least an an issue ticket to the docs repo to add instructions to alter guardrails in the customization section of the docs Maybe a popup/alert should happen whenever it’s reset? It could declare the enforced limits |
And not sure if some actual guardrails should be included in this PR or wait for a future PR, but here are some suggestions: Max Daily Safety Multiplier: |
I think it's is incredibly important to define. IMO throwing a pop-up telling people that this is changed (on save), and then we should have a discussion on what should happen after that. I can see the following ways of handling it:
I am not personally sure which approach is better. |
The 90 g min limit did clamp values below to 90. There was no max value, so I don’t know if the same happens when above (clamping to the closest limit?) |
I can confirm that the current implementation clamps the setting to the closest limit, after testing to introduction of an arbitrary max limit as well:
(settings in between are accepted as is) |
Just tested this on some max/min for decimal prefs. Works as suggested and if going beyond min/max it will restricted to applicable min/max. On Bool prefs it throws an error while configuring it. So all good!!v |
I suggest to define the min/max limits in FreeAPS/Sources/Models/Preferences.swift though, instead of in the FreeAPS/Sources/Modules/PreferencesEditor/PreferencesEditorStateModel.swift |
That might be a good idea for maintainability, then defaults and min/max limits could be stored the same place? So here: Instead of here: Trio/FreeAPS/Sources/Modules/PreferencesEditor/PreferencesEditorStateModel.swift Line 448 in 1941a02
@JeremyStorring , thoughts? |
I can definitely give this a shot, but it might be a bit harder to implement :) |
I tested the PR with success.
You could use the same approach as the key path with this suggestion (I quickly tested) :
and after just to write each min / max with :
and specify in preferences.swift :
|
53ededa
to
d68b887
Compare
Oh boy I completely misunderstood what was being asked, yeah this makes sense and I think would be a better implementation! I didn't actually add min and max values, but it works as intended once we updated Preferences. Also disregard git fail from above :P |
Thanks! Could you please add min/max limits for one or more of the settings that are likely to be agreement on, as an example to ease the code review and testing? Such as: Weight of past 24hr vs 10days: 0 - 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.
I tested it with the threshold setting for 60-120 and it worked as expected.
I think a popup alert notifying the user that their entry has been nudged would be nice, but that could be a new PR.
As. this only adds functionality to limit preferences and does not actually introduce any limits (for now) LGTM. |
Merging with 2 approvals and mine😇 |
PreferencesEditorDataFlow: commit Xcode auto formatting related to #232
Closes #189
I've made it so that remaining carbs cap will not go less than 90 based on the docs. I've also added the functionality to set constraints to values (any safety setting we decide on in the future).