Scan: throttled Erfolgs-Log + sichtbare Decode-Fehler statt stillem catch
All checks were successful
Pin to IPFS / pin (push) Successful in 10s

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Niels Göttsch 2026-06-15 08:26:34 +02:00
parent 753e210b15
commit 1dbeb16e86

19
app.js
View file

@ -135,6 +135,12 @@
const c = $(canvasId);
const ctx = c.getContext('2d', { willReadFrequently: true });
let lastScan = 0;
let lastLog = 0;
const logThrottled = (now, msg) => {
if (now - lastLog < 1000) return;
lastLog = now;
addPairingLog(msg);
};
const detect = barcodeDetector
? async () => {
@ -153,13 +159,20 @@
if (!v.videoWidth) { camRaf = requestAnimationFrame(tick); return; }
if (now - lastScan < 100) { camRaf = requestAnimationFrame(tick); return; }
lastScan = now;
let raw = null;
try {
const raw = await detect();
raw = await detect();
if (raw) {
const p = await unpack(raw);
if (p.v === 1) { callback(p, raw); return; }
if (p.v === 1) {
logThrottled(now, 'QR gescannt ✓');
callback(p, raw);
return;
}
}
} catch (e) {
if (raw) logThrottled(now, `QR gescannt, aber ungültige Daten: ${e.message}`);
}
} catch (_) {}
camRaf = requestAnimationFrame(tick);
});
}