From 99f52aa7d1bf7a333787daf226dae24611e32a90 Mon Sep 17 00:00:00 2001 From: gjulivan Date: Tue, 13 Jan 2026 14:47:27 +0100 Subject: [PATCH 1/2] fix: take picture only removes button when video failed to load. --- .../webactions/actions/TakePicture.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/javascriptsource/webactions/actions/TakePicture.js b/javascriptsource/webactions/actions/TakePicture.js index d01d076..b7ef788 100644 --- a/javascriptsource/webactions/actions/TakePicture.js +++ b/javascriptsource/webactions/actions/TakePicture.js @@ -55,6 +55,7 @@ export async function TakePicture(picture, showConfirmationScreen, pictureQualit let stream; let videoIsReady = false; let shouldFaceEnvironment = true; + let retryAttempt = 0; const { video, wrapper, @@ -84,12 +85,30 @@ export async function TakePicture(picture, showConfirmationScreen, pictureQualit }); switchControl.addEventListener("click", switchControlHandler); actionControl.addEventListener("click", () => { + + if(!videoIsReady){ + // reload video if not ready yet (some devices need this extra step) + if(retryAttempt < 3){ + retryAttempt++; + } else { + actionControl.disabled = true; + mx.ui.error(getUserText("Media not available.", "Media niet beschikbaar.")); + return; + } + video.load(); + setTimeout(() => { + actionControl.click(); + },50); + return; + } + removeAllControlButtons(); if (showConfirmationScreen) { // Delay the `takePictureHandler` to the next cycle so the UI preparations can go first. Otherwise, the control-buttons are not removed while the second screen is being set up. setTimeout(() => { takePictureHandler(() => { addAllControlButtons(); + retryAttempt = 0; video.play(); }); }, 0); From 75f924f26be90eab3c0c8eecf5e419c0e4cb45a7 Mon Sep 17 00:00:00 2001 From: gjulivan Date: Mon, 19 Jan 2026 13:29:09 +0100 Subject: [PATCH 2/2] fix: formatting and control disabling --- javascriptsource/webactions/actions/TakePicture.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/javascriptsource/webactions/actions/TakePicture.js b/javascriptsource/webactions/actions/TakePicture.js index b7ef788..4f19191 100644 --- a/javascriptsource/webactions/actions/TakePicture.js +++ b/javascriptsource/webactions/actions/TakePicture.js @@ -87,18 +87,18 @@ export async function TakePicture(picture, showConfirmationScreen, pictureQualit actionControl.addEventListener("click", () => { if(!videoIsReady){ + actionControl.disabled = true; // reload video if not ready yet (some devices need this extra step) if(retryAttempt < 3){ retryAttempt++; } else { - actionControl.disabled = true; mx.ui.error(getUserText("Media not available.", "Media niet beschikbaar.")); return; } video.load(); setTimeout(() => { actionControl.click(); - },50); + }, 50); return; } @@ -120,6 +120,8 @@ export async function TakePicture(picture, showConfirmationScreen, pictureQualit closeControlHandler(); }); } + + actionControl.disabled = false; }); video.addEventListener("loadedmetadata", () => (videoIsReady = true)); function getVideoCanvas() {