Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there way to set initial value of the settings based on the user settings

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?

Best Answer
0 Votes
4 REPLIES 4

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'.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Thank you! I'll take a look

Best Answer
0 Votes

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

Best Answer
0 Votes

found your response to a similar question which worked

Best Answer