Fix duplicate scans from concurrent scan listeners - #436
Closed
jmiranda wants to merge 1 commit into
Closed
Conversation
useScanListener added a DeviceEventEmitter listener per enabled consumer. A single hardware scan produces one intent broadcast, which the emitter dispatches to every registered listener, so when two ScannerInputs are mounted together — e.g. a screen input and a modal dialog input during a dialog open/close transition — both handled the same scan and the value was applied twice. Route scans through a single shared subscription and deliver each scan to only the most recently enabled consumer (top of a listener stack), so the scanner is owned by one listener at a time. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018esj4qV5h4teD7M6WfHahM
jmiranda
force-pushed
the
claude/fix-duplicate-scan-listener
branch
from
August 5, 2026 18:19
ae36d0f to
2acd681
Compare
jmiranda
force-pushed
the
claude/fix-duplicate-scan-listener
branch
from
August 5, 2026 18:37
79608c8 to
2acd681
Compare
Member
Author
|
Closing to temporarily halt the bitrise builds that are being triggered. cc @awalkowiak |
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.
Follow-up to #423 (OBLS-822).
Problem
A single hardware scan produces exactly one DataWedge intent broadcast, which
DeviceEventEmitterdispatches to every registered listener.useScanListeneradds one listener per enabled consumer, so whenever twoScannerInputs are mounted at the same time the same scan is handled twice and the value is applied twice.This happens on screens that pair a screen-level
ScannerInputwith a modal dialog that contains its ownScannerInput(e.g.SortationContainerScreen+ContainerMismatchDialog,PutawayLocationScanScreen,PutawayQuantityScreen). Each screen disables one input while the other is active (isEnabled={!isDialogVisible ...}), but during the dialog open/close transition both inputs can be subscribed for a moment, and a scan in that window is delivered to both listeners.This is not native-receiver stacking:
react-native-datawedge-intentsreuses a singlegenericReceiverand unregisters it before re-registering, so there is only ever one native receiver and one emit per scan. The duplication is purely on the JS listener side.Change
DeviceEventEmittersubscription.ScannerInputs being briefly subscribed together: only the active (top-of-stack) one handles the scan.This preserves the existing
enabledgating onuseScanListener(ScannerInputstill passesshouldBeFocused) and matches the codebase invariant of one scanner input per screen;useBarcodeScannedis unchanged.How to test (no Zebra required)
Open the inbound sortation flow (Sortation → scan product → container screen), then from a connected device/emulator:
adb shell am broadcast -a com.openboxes.android.ACTION --es com.symbol.datawedge.data_string "0123456789" --es com.symbol.datawedge.label_type "LABEL-TYPE-CODE128"The value should be applied once. Also exercise the container-mismatch dialog (scan a wrong container to open it, then scan again inside the dialog) and confirm no double entry/submit across the dialog transition.
Not covered here
DataWedge Keystroke output is still enabled alongside Intent output, so a scan is also typed into the focused field. That's a separate potential duplicate source (would show as doubled/appended text or a double submit, including on single-input screens with no dialog). Left out of this PR; can be addressed separately if it turns out to be a real symptom in practice.
🤖 Generated with Claude Code