fix #2: header pill refreshes itself after swipes, undo and new batches
loadStats() only ran once at boot, so the live/fresh/new pill (and the list sub-line) went stale until a full reload. Refresh it, debounced and fire-and-forget, after any decision change, when a new batch lands, and on app foreground. Adds two fe_walk_v11 regression checks + a UI-SPEC note.
This commit is contained in:
@@ -415,6 +415,7 @@ function setDecision(id, act, secId=null, photoIdx=null){
|
||||
localDecisions.set(id, act);
|
||||
updateRowDecision(id, act); // optimistic paint
|
||||
enqueue(id, act, secId, photoIdx);
|
||||
refreshStats(); // v1.1.1 (#2): every decision change nudges the header counters
|
||||
}
|
||||
|
||||
/* ---------- payload -> display helpers ---------- */
|
||||
@@ -660,6 +661,7 @@ async function loadSection(){
|
||||
buffer.push(...fresh);
|
||||
fillPile();
|
||||
updateSectionUI(body);
|
||||
refreshStats(); // v1.1.1 (#2): a new batch landed — freshen the counters
|
||||
}catch(e){ setTimeout(()=>loadSection(),15000); }
|
||||
finally{ deckLoading=false; }
|
||||
maybeRefill();
|
||||
@@ -1206,6 +1208,19 @@ async function loadStats(){
|
||||
fetch('/api/badge/seen',{method:'POST'}).catch(()=>{});
|
||||
}
|
||||
}
|
||||
/* v1.1.1 (issue #2): loadStats only ran at boot, so the header pill and the
|
||||
list sub-line went stale after every swipe until a full reload. Refresh
|
||||
shortly after any decision change (swipes, undo, dossier/list/matches
|
||||
edits) and whenever a new batch lands. Coalesced + fire-and-forget: a
|
||||
swipe never waits on it. */
|
||||
let statsTimer=null;
|
||||
function refreshStats(){
|
||||
if(statsTimer) return; // bursts collapse into one read
|
||||
statsTimer=setTimeout(()=>{ statsTimer=null; loadStats(); },600);
|
||||
}
|
||||
/* foreground/resume: catch anything that changed while the app slept
|
||||
(e.g. the 08:30 import) without waiting for the next swipe */
|
||||
document.addEventListener('visibilitychange',()=>{ if(!document.hidden) refreshStats(); });
|
||||
|
||||
/* ---------- P3 section UI: progress pill + report + forge + modes ---------- */
|
||||
let sectDecided=0, sectTotal=0;
|
||||
@@ -1297,6 +1312,7 @@ $('btnForge').onclick=async()=>{
|
||||
buffer.push(...fresh);
|
||||
fillPile();
|
||||
updateSectionUI(body);
|
||||
refreshStats(); // v1.1.1 (#2): forged batch — freshen the counters
|
||||
if(pile.length){ $('report').classList.remove('on'); }
|
||||
// item 8: a zero-item forge on a fully drained catalog -> empty2,
|
||||
// no lone Forge button inviting a wasted agent run
|
||||
|
||||
Reference in New Issue
Block a user