From 25e0efa1d8ae722ffa31dbfce9aafe5b69dbbbc2 Mon Sep 17 00:00:00 2001 From: "afiq.hamzah" Date: Mon, 13 Feb 2023 15:28:59 +0800 Subject: [PATCH] Opt for the last device assumed as doccamera when using Firefox --- public/js/marhun-photo-capture.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/public/js/marhun-photo-capture.js b/public/js/marhun-photo-capture.js index 9c1913e7..ed29df11 100644 --- a/public/js/marhun-photo-capture.js +++ b/public/js/marhun-photo-capture.js @@ -106,9 +106,17 @@ function marhunPhotoCapturerFactory(modal_selector) { return marhun_camera_config_firefox.includes(camera.deviceId); }); - if(filteredCameraFirefox.length > 0){ - return filteredCameraFirefox.at(-1); - } + + let isfirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; + if(isfirefox){ + + if(filteredCameraFirefox.length > 0){ + return filteredCameraFirefox.splice(-1); + } + + const filteredCameraFirefoxLastDevice = available_cameras.splice(-1); + return filteredCameraFirefoxLastDevice; + } // Get the first available priority referencing to env return filteredCameraChrome.at(-1);