fix(qr-scan): gate CameraView on permission + surface unrecognized QR#85
Draft
epicexcelsior wants to merge 2 commits into
Draft
fix(qr-scan): gate CameraView on permission + surface unrecognized QR#85epicexcelsior wants to merge 2 commits into
epicexcelsior wants to merge 2 commits into
Conversation
d78415f to
c5767b7
Compare
Two related iOS bugs observed on a personal-team dev build: 1. CameraView mounted before permission resolved → black preview that never recovers until app restart. On iOS the component caches its permission state at mount; flipping null→granted at runtime doesn't re-init the preview. Gate the mount on `permission.granted === true` so the conditional flip causes a fresh mount with permission in place. 2. PeersDrawer's QR onResult silently dropped any QR that wasn't a plain LXMF hash — group QRs, Solana addresses, malformed/empty payloads all closed the modal with no feedback, leaving users thinking "scanner is broken." Surface explicit alerts: - lxmf-group → "looks like a channel QR, use Join channel" - solana → "wallet address, use Send screen" - unknown → show first 64 chars of raw payload so user can debug Also adds a __DEV__ console.log of the parsed result so we can adb logcat-trace exactly what came out of the scanner.
expo-camera@17 split audio recording into a separate package (expo-audio). iOS native side hard-links the ExpoAudio module even when the JS-level use is barcode-scanning only, so the dev-client build fails with "Cannot find native module expoAudio" without the peer dep installed. `npx expo install expo-audio` added 1.1.1 to deps and registered the config plugin in app.json. No source code changes — this is pure native bridge availability.
3db3829 to
590ae74
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related iOS QR-scan bugs, both reproduced on personal-team dev build (no public team certs). Critical because "impossible to find peers" was the user's symptom — QR scan is the primary peer-discovery path.
Bug 1 — Black camera preview until app restart
Cause: `CameraView` from expo-camera caches its permission state at mount time on iOS. If we render it before the OS prompt has resolved (the natural flow when a first-time user taps the scanner button), the preview shows black and never recovers, even after the user taps "Allow." Only an app restart fixes it, because a fresh mount captures the now-granted permission.
Fix: gate `CameraView` rendering on `permission?.granted === true`. While permission is pending or null, show a "Requesting camera access…" placeholder. When the OS grants permission, the conditional flips and `CameraView` mounts fresh with the right state.
Bug 2 — Scan succeeds, modal closes, nothing happens
Cause: `PeersDrawer` onResult only handled `result.type === 'lxmf'`. Any other type (`lxmf-group`, `solana`, `unknown`) silently closed the modal. From the user's perspective: scanner opened, recognized the QR, then nothing — looks broken.
Fix: explicit feedback for every result type:
Diagnostic
Added a `DEV` console.log dump of the parsed scan result inside PeersDrawer onResult. Lets us adb logcat-trace exactly what the parser returned, which helps if any peer QR formats in the wild don't match the existing regex.
Scope
Two-file diff, conservative. No native config touched.
Test plan (iOS dev build)
Rollback
`git revert` — two-file diff, no permission descriptor changes.