Skip to content

fix: debounce clicks and deduplicate scans#832

Open
ovitrif wants to merge 20 commits intomasterfrom
fix/accidental-db-clicks
Open

fix: debounce clicks and deduplicate scans#832
ovitrif wants to merge 20 commits intomasterfrom
fix/accidental-db-clicks

Conversation

@ovitrif
Copy link
Collaborator

@ovitrif ovitrif commented Mar 9, 2026

Fixes #831

This PR:

  1. Adds click debouncing across all interactive UI elements to prevent accidental double-taps
  2. Ensures only one scan job runs at a time, deduplicating concurrent scan inputs from paste, scanner, deep links, and address entry

Description

Rapid taps on clickable elements (buttons, navigation icons, tabbar buttons, drawer items, overlays, etc) could trigger duplicate actions (double navigations, duplicate payments, etc.). A ClickDebouncer utility with a 500ms window is added and exposed as rememberDebouncedClick. All interactive surfaces now route through debounced click handlers.

The scan deduplication consolidates four separate handleScan() call sites into a single launchScan() method that tracks the active scan job and input, cancelling prior scans when a new one arrives and skipping exact duplicates.

Preview

Before Multi Clicks Multi Paste
before.mp4
multiClicks.mp4
multiPaste.mp4

QA Notes

1. Button debouncing

  1. Open the app and navigate to any screen with buttons (e.g. Send, Receive, Settings)
  2. Rapidly multi-tap on any button
  3. Verify only one action is triggered (no duplicate actions)

2. Navigation debouncing

  1. Tap the back arrow or any navigation components rapidly (ie. Settings clickables)
  2. Verify no double navigation occurs

3. Tabbar buttons and drawer items

  1. Rapidly tap between bottom tabbar buttons
  2. Open the drawer and fast multi tap menu items
  3. Verify smooth single-action behavior

4. Scan deduplication - bug: #831

  1. Enable QuickPay & copy a LN invoice with amount below treshold
  2. Rapidly multi tap Paste buttons on scanner or Send sheet
  3. Verify only one scan processes (check logs for "Skipping duplicate scan")
  4. Verify scan and quickpay proceeds without issues

5. Overlay and sheet dismissal

  1. Tap the scrim/overlay area of a bottom sheet rapidly
  2. Verify it dismisses once without flicker

@ovitrif ovitrif self-assigned this Mar 9, 2026
@ovitrif ovitrif added this to the 2.2.0 milestone Mar 9, 2026
claude[bot]

This comment was marked as outdated.

claude[bot]

This comment was marked as resolved.

@ovitrif ovitrif force-pushed the fix/accidental-db-clicks branch from de7f517 to 714d493 Compare March 10, 2026 18:45
@ovitrif

This comment was marked as resolved.

@claude

This comment has been minimized.

Copy link
Member

@jvsena42 jvsena42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found this bug when double tapping the NumberPad

Screen_recording_20260311_143238.webm

@ovitrif

This comment was marked as resolved.

@ovitrif
Copy link
Collaborator Author

ovitrif commented Mar 11, 2026

Fixed the NumberPad double-tap issue in 32711b8 — added a debounce parameter to clickableAlpha (defaults to 500ms) and set debounce = Duration.ZERO on NumberPad keys so rapid presses aren't swallowed.

Preview

fix.mp4

@ovitrif ovitrif requested a review from jvsena42 March 11, 2026 22:52
@ovitrif ovitrif force-pushed the fix/accidental-db-clicks branch from 32711b8 to 72ce56a Compare March 12, 2026 01:09
@ovitrif
Copy link
Collaborator Author

ovitrif commented Mar 12, 2026

Addressed both review comments in fb7168a:

  • ClickableAlpha.kt: Added else branch to restore alpha to 1f when tap is debounced
  • AppViewModel.kt: Log message now starts with verb: "Starting scan from ..."

@ovitrif ovitrif dismissed jvsena42’s stale review March 13, 2026 04:00

needs re-review

ovitrif and others added 8 commits March 13, 2026 22:15
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ovitrif and others added 12 commits March 13, 2026 22:15
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ovitrif ovitrif force-pushed the fix/accidental-db-clicks branch from fb7168a to 6fe4f4a Compare March 13, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Double tap on Paste invoice triggers duplicate QuickPay payment

2 participants