06-26-2021 12:02
06-26-2021 12:02
I'd like to initialize a toggle to the value of the user settings.
E.g., in the settings section of the companion app I have a toggle to switch between "km" and "mi" for distance calculations. I'd like to set its initial value to the current user settings (units.distance)
Is there a way to do so?
06-26-2021 13:57
06-26-2021 13:57
I think this would be possible, but may be slow and messy.
You should be able to initialise the toggle using something like
settingsStorage.setItem(milesSetting, useMiles?'true':'false')
You'd have to get milesSetting by sending it from the watch. This would incur a small delay.
Do you really need for the user to be able to override the preference they've set up in their account?
If so, I'd think about using a <select> so the user could choose 'Miles' or 'km'.
06-26-2021 15:29
06-26-2021 15:29
Thank you! I'll take a look
06-26-2021 17:40 - edited 06-26-2021 17:42
06-26-2021 17:40 - edited 06-26-2021 17:42
Either I'm not doing it right or it doesn't work.
I decided to follow your advice and change toggle to a select.
When I call, for example
settingsStorage.setItem("settingsKeyName", 1)
The selection doesn't get set to the second option
06-26-2021 17:47
06-26-2021 17:47
found your response to a similar question which worked