aboutsummaryrefslogtreecommitdiff
path: root/source/ui/OtpView.mc
diff options
context:
space:
mode:
Diffstat (limited to 'source/ui/OtpView.mc')
-rw-r--r--source/ui/OtpView.mc11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/ui/OtpView.mc b/source/ui/OtpView.mc
index faf94d0..1c0c0bd 100644
--- a/source/ui/OtpView.mc
+++ b/source/ui/OtpView.mc
@@ -258,6 +258,11 @@ class OtpView extends WatchUi.View {
// Input on the OTP detail: START or a tap gives the next HOTP code; BACK closes.
class OtpDelegate extends WatchUi.BehaviorDelegate {
+ // One tap can arrive twice (as START and as a tap); a second "next
+ // code" within this time is ignored so the counter moves only once.
+ static const NEXT_DEBOUNCE_MS = 500;
+ private var _lastNextMs as Number? = null;
+
function initialize() {
BehaviorDelegate.initialize();
}
@@ -294,6 +299,12 @@ class OtpDelegate extends WatchUi.BehaviorDelegate {
if (v == null || !v.isHotp()) {
return;
}
+ var now = System.getTimer();
+ var last = _lastNextMs;
+ if (last != null && now - last >= 0 && now - last < NEXT_DEBOUNCE_MS) {
+ return;
+ }
+ _lastNextMs = now;
try {
AppState.theVault().setCounter(v.header.id, v.header.counter + 1);
} catch (e instanceof VaultError) {