Vote presence: codes may span the enrollment slack as long as one is fresh (slow phones hit 'scan expiré' with 5 scans); phone drops codes too old to count

This commit is contained in:
2026-11-17 14:14:56 +01:00
parent d761d8b510
commit 0697c27a01
3 changed files with 16 additions and 6 deletions
+5
View File
@@ -453,9 +453,14 @@ function collectPresence(n) {
paint();
$("#p-msg").textContent = "";
dlg.showModal();
const seenAt = new Map();
const sc = makeScanner($("#p-video"), (t) => {
if (got.length >= n || got.includes(t)) return;
// the server takes codes spread over ~8 s + n intervals: on a slow phone the oldest ones lapse, drop them
const now = performance.now();
while (got.length && now - seenAt.get(got[0]) > 9000) got.shift();
got.push(t);
seenAt.set(t, now);
paint();
navigator.vibrate?.(15);
if (got.length >= n) setTimeout(() => finish(got), FILL_MS);