Skip to content

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

Merged
bra1nDump merged 1 commit intoslopus:mainfrom
dzlobin:fix/45-camera-dismiss-on-unmount
Apr 13, 2026
Merged

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

Conversation

@dzlobin
Copy link
Copy Markdown

@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.
leeroybrun added a commit to happier-dev/happier that referenced this pull request Feb 14, 2026
@happier-bot

This comment was marked as abuse.

@bra1nDump bra1nDump merged commit 4b13554 into slopus:main Apr 13, 2026
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

3 participants