diff options
Diffstat (limited to 'source/ui/Nav.mc')
| -rw-r--r-- | source/ui/Nav.mc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/source/ui/Nav.mc b/source/ui/Nav.mc index 222386a..af08d4a 100644 --- a/source/ui/Nav.mc +++ b/source/ui/Nav.mc @@ -2,13 +2,31 @@ // Summary: Navigation between screens (README 13.2): opening entries, asking for the PIN first when needed, the menu. import Toybox.Lang; +import Toybox.System; import Toybox.WatchUi; module Nav { + // A second open request within this time is the same tap delivered + // twice (as START in onKey and as onTap) and is ignored. + const OPEN_DEBOUNCE_MS = 500; + var _lastOpenMs as Number? = null; + // Open an entry from the list: its detail screen, or the PIN screen first - // when it is locked and the session is locked. + // when it is locked and the session is locked. Ignored while a PIN or + // detail screen is already on top, or right after another open, so one + // tap can't push two screens. function openEntry(id as String) as Void { + var top = WatchUi.getCurrentView()[0]; + if (top instanceof PinView || top instanceof OtpView || top instanceof CodeView) { + return; + } + var now = System.getTimer(); + var last = _lastOpenMs; + if (last != null && now - last >= 0 && now - last < OPEN_DEBOUNCE_MS) { + return; + } + _lastOpenMs = now; var vault = AppState.theVault(); var header = vault.header(id); if (header == null) { |
