Skip to content

fix: dismiss camera on unmount and prevent duplicate scans#541

Open
dzlobin wants to merge 1 commit intoslopus:mainfrom
dzlobin:fix/45-camera-dismiss-on-unmount
Open

fix: dismiss camera on unmount and prevent duplicate scans#541
dzlobin wants to merge 1 commit intoslopus:mainfrom
dzlobin:fix/45-camera-dismiss-on-unmount

Conversation

@dzlobin
Copy link

@dzlobin dzlobin commented Feb 4, 2026

Summary

  • Dismisses iOS camera scanner in useEffect cleanup so it stops when the component unmounts
  • Adds useRef guard to prevent duplicate scan processing from rapid barcode events
  • Wraps scan handler in try/finally so the guard resets even if processAuthUrl throws
  • Applied to both useConnectAccount and useConnectTerminal hooks

Root Cause

dismissScanner() was only called inside the URL pattern check within the scan handler. If the component unmounted before or without a successful scan, the camera stayed active. Additionally, multiple barcode events could fire before the first finished processing.

Closes #45

Test plan

  • iOS: Scan QR code, verify camera dismisses immediately
  • iOS: Navigate away mid-scan, verify camera stops
  • Android: Verify no behavioral change (auto-dismiss on scan)

🤖 Generated with Claude Code

…lopus#45)

Camera stayed active on iOS after scanning a QR code because
dismissScanner was only called inside the URL pattern check with
no cleanup on effect unmount. Adds useRef guard to prevent duplicate
scan processing, try/finally to ensure guard reset, and dismissScanner
in useEffect cleanup.
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.

Camera is still capturing after successfully capturing QR code

1 participant