mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-10 02:47:49 +00:00
[UI] Handle duplicate cameras (#13167)
Fixes https://github.com/inventree/InvenTree/issues/13164
This commit is contained in:
1 parent
bc8c1aefa2
commit
2310b54e26
1 file changed
+10
-2
@@ -112,8 +112,16 @@ export default function BarcodeCameraInput({
|
||||
legacyScannerRef.current = new Html5Qrcode('reader');
|
||||
}
|
||||
|
||||
Html5Qrcode.getCameras().then((devices) => {
|
||||
if (devices?.length) {
|
||||
Html5Qrcode.getCameras().then((cameraList) => {
|
||||
// Some browsers (e.g. Firefox on Linux) can report the same physical
|
||||
// camera more than once with an identical deviceId. Mantine's Select
|
||||
// throws on duplicate option values, so de-duplicate by id here.
|
||||
const devices = (cameraList ?? []).filter(
|
||||
(device, index, list) =>
|
||||
list.findIndex((other) => other.id === device.id) === index
|
||||
);
|
||||
|
||||
if (devices.length) {
|
||||
setCameras(devices);
|
||||
|
||||
// Auto-select a camera so the play button is immediately usable,
|
||||
|
||||
Reference in new issue
Block a user