From fa5fa12157f7384796fc93507812d003dd08e0de Mon Sep 17 00:00:00 2001 From: Grzegorz Kucmierz Date: Fri, 13 Feb 2026 06:14:51 +0100 Subject: [PATCH] fix: resetGrid visibility in puzzle store and hide camera switch on single-cam devices --- src/components/ImageImportModal.vue | 9 ++++++++- src/stores/puzzle.js | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/ImageImportModal.vue b/src/components/ImageImportModal.vue index e0fd4b3..f2bd08d 100644 --- a/src/components/ImageImportModal.vue +++ b/src/components/ImageImportModal.vue @@ -18,6 +18,7 @@ const imageLoaded = ref(false); const processing = ref(false); const processingProgress = ref(0); const isCameraOpen = ref(false); +const hasMultipleCameras = ref(false); const stream = ref(null); const facingMode = ref('environment'); @@ -319,6 +320,12 @@ const startCamera = async () => { } }; stream.value = await navigator.mediaDevices.getUserMedia(constraints); + + // Check available devices + const devices = await navigator.mediaDevices.enumerateDevices(); + const videoDevices = devices.filter(device => device.kind === 'videoinput'); + hasMultipleCameras.value = videoDevices.length > 1; + // Wait for next tick or ensure videoRef is available setTimeout(() => { if (videoRef.value) { @@ -401,7 +408,7 @@ onUnmounted(() => { - diff --git a/src/stores/puzzle.js b/src/stores/puzzle.js index 470f8a7..1d942ed 100644 --- a/src/stores/puzzle.js +++ b/src/stores/puzzle.js @@ -118,13 +118,15 @@ export const usePuzzleStore = defineStore('puzzle', () => { elapsedTime.value = 0; startTimer(); saveState(); + } + function resetGrid() { const rows = solution.value.length; const cols = solution.value[0].length; playerGrid.value = Array(rows).fill().map(() => Array(cols).fill(0)); history.value = []; moves.value = 0; - } currentTransaction.value = null; + currentTransaction.value = null; } function startInteraction() {