Skip to content

Commit 8416961

Browse files
committed
Fix period-filter dropdown permanently stuck on empty options
loadPendingPeriods() cached its result via a one-shot periodsReady flag that, once true, was never reset except by a Manage Periods save. If the dropdown got focused before the citizen list's first load finished (e.g. right after login, made more likely by the recent debounce added to refreshDashboard), it would compute against an empty allCitizens, find no periods, and set periodsReady=true anyway -- permanently showing only "All pending (any period)" for the rest of the session, even once the real data arrived. refreshDashboard now resets periodsReady/unpaidCache every time it repopulates allCitizens, so the next dropdown focus (or an already-active period filter) recomputes against current data instead of being stuck on a stale/empty snapshot.
1 parent 8d0ae63 commit 8416961

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,16 @@ <h4>Pending UPI payments <span id="pendingCount" class="pending-badge">0</span><
11741174
}
11751175
if(seq !== dashboardRefreshSeq) return; // superseded by a newer refresh; drop this stale result
11761176
allCitizens = list;
1177+
// The period dropdown's cache (unpaidCache/periodsReady) was built from
1178+
// whatever allCitizens looked like at the time it was requested. If that
1179+
// happened before the very first citizen list arrived (e.g. someone opens
1180+
// the dropdown right after login), it would otherwise permanently cache an
1181+
// empty result — periodsReady stays true forever with no periods listed.
1182+
// Invalidating it here means the next dropdown focus (or an already-active
1183+
// period filter, re-checked by renderList below) recomputes against
1184+
// current data instead of a possibly-stale/empty snapshot.
1185+
periodsReady = false;
1186+
unpaidCache = new Map();
11771187
renderStats(); renderList(); refreshPending();
11781188
}
11791189
function renderStats(){

0 commit comments

Comments
 (0)