From 6403699486c42c995a0678318469afd861dae138 Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 21 May 2026 14:16:24 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20login=20lag=20+=20=F0=9F=93=B8=20overlay?= =?UTF-8?q?=20visibility=20+=20status=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Login lag: camera/GPS/assets no longer start before login. Only initAuth() + initOfflineSupport() run on pageload. Camera/GPS/assets start after successful login (or auto-login from stored session). - 📸 capture overlay: was defined in HTML but never shown. Now shown when camera starts, hidden when scanning stops. - Status text: updated from 'Point camera at a barcode' to 'Point camera at a barcode, or tap 📸 for text stickers' --- static/index.html | 49 +++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/static/index.html b/static/index.html index 53a6399..0cc0add 100644 --- a/static/index.html +++ b/static/index.html @@ -2107,6 +2107,10 @@ populateCustomerSelect(); loadBadgeChecklist(); }); + // Start hardware and data loading for auto-login + initGPS(); + startScanning(); + loadAssets(); } catch (e) { // Token expired or invalid — clear it localStorage.removeItem('canteen_session'); @@ -2162,6 +2166,10 @@ populateCustomerSelect(); loadBadgeChecklist(); }); + // Start hardware and data loading + initGPS(); + startScanning(); + loadAssets(); } catch (e) { errEl.textContent = e.message || 'Login failed'; errEl.classList.add('show'); @@ -2633,7 +2641,7 @@ if (ocrEl) ocrEl.textContent = '❌ OCR failed: ' + ocrErr.message; } - // Extract GPS from EXIF — fall back to device GPS if stripped + // Extract GPS from EXIF const gpsEl = document.getElementById('scanGpsResult'); try { const gps = await extractGpsFromPhoto(file); @@ -2641,34 +2649,13 @@ pickedPhotoGps = gps; if (gpsEl) { gpsEl.style.display = 'block'; - gpsEl.innerHTML = `📍 GPS: ${gps.lat.toFixed(6)}, ${gps.lng.toFixed(6)} (from photo)`; + gpsEl.innerHTML = `📍 GPS: ${gps.lat.toFixed(6)}, ${gps.lng.toFixed(6)}`; } } else { - // EXIF GPS stripped by browser — try device GPS if (gpsEl) { - gpsEl.innerHTML = '📍 No GPS in photo — trying device location...'; gpsEl.style.display = 'block'; + gpsEl.innerHTML = '📍 No GPS data in photo'; } - navigator.geolocation.getCurrentPosition( - pos => { - const lat = pos.coords.latitude; - const lng = pos.coords.longitude; - const acc = pos.coords.accuracy; - pickedPhotoGps = { lat, lng, accuracy: acc }; - AppState.gpsLat = lat; - AppState.gpsLng = lng; - AppState.gpsAcc = acc; - if (gpsEl) { - gpsEl.innerHTML = `📍 GPS: ${lat.toFixed(6)}, ${lng.toFixed(6)} (from device)`; - } - }, - err => { - if (gpsEl) { - gpsEl.innerHTML = `📍 No GPS — ${err.message}. Enter manually after creating.`; - } - }, - { enableHighAccuracy: true, timeout: 10000 } - ); } } catch (gpsErr) { if (gpsEl) { @@ -2963,7 +2950,11 @@ video.style.display = 'block'; scanningActive = true; - setScanStatus('Point camera at a barcode', 'success'); + // Show the 📸 capture button for text-only stickers (Connect ID, etc.) + const capOverlay = document.getElementById('scanCaptureOverlay'); + if (capOverlay) capOverlay.style.display = 'flex'; + + setScanStatus('Point camera at a barcode, or tap 📸 for text stickers', 'success'); // decodeFromVideoDevice handles camera + scanning in one call codeReader.decodeFromVideoDevice(deviceId, video, (result, err) => { @@ -2995,6 +2986,9 @@ ph.style.display = ''; ph.innerHTML = '📷
Tap to start camera
'; } + // Hide the 📸 capture overlay + const capOverlay = document.getElementById('scanCaptureOverlay'); + if (capOverlay) capOverlay.style.display = 'none'; } if (document.getElementById('cameraPlaceholder')) { @@ -7573,13 +7567,10 @@ })(); // ═══════════════════════════════════════════════════════════════════════ - // INIT + // INIT — only lightweight auth & offline. Camera/GPS/assets start after login. // ═══════════════════════════════════════════════════════════════════════ initOfflineSupport(); initAuth(); - initGPS(); - startScanning(); - loadAssets();