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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user