ch1bo / garmin-otp-authenticator

Garmin ConnectIQ Widget for One Time Passwords (HOTP / TOTP / Steam Guard)
Mozilla Public License 2.0
77 stars 14 forks source link

Save providers when leaving widget #10

Closed JuanPotato closed 4 years ago

JuanPotato commented 4 years ago

This saves the updated counter for counter OTPs.

Before, the counter would just increase but would reset back to zero when the widget was opened again.

The code responsible for updating the counter is https://github.com/ch1bo/garmin-otp-authenticator/blob/f690f695d97a004abaacb33582eb51f4a764c948/src/MainView.mc#L129-L133 which updates the count but never explicitly saves it. This PR makes sure things get saved. I was debating on if it would be better to only call saveProviders when we update the counter in that above code instead of saving on exit.

ch1bo commented 4 years ago

Good catch! IIRC other modifications do save right way so doing the same when modifying the counter would be viable as well, i.e. when updating name or key as currently drafted in the editing branch.

I'd say, lets merge this and if we want we can also add saveProviders to the counter incrementing code (ought to be refactored anyways).