fix: leaderboard empty on first open — decouple from loadAll()

- Add isLeaderboardLoading flag separate from isLoading
- Add loadLeaderboard() method that fires independently of loadAll TTL
- Remove leaderboard from loadAll() Future.wait (failures in dashboard/shop
  no longer silently zero-out leaderboard data)
- setDistrict / setTimePeriod now use isLeaderboardLoading
- contribute_screen calls loadLeaderboard() alongside loadAll() on mount

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 00:35:51 +05:30
parent 7bc396bdde
commit 4c57391bbd
2 changed files with 36 additions and 11 deletions

View File

@@ -104,7 +104,9 @@ class _ContributeScreenState extends State<ContributeScreen>
super.initState();
PostHogService.instance.screen('Contribute');
WidgetsBinding.instance.addPostFrameCallback((_) {
context.read<GamificationProvider>().loadAll();
final p = context.read<GamificationProvider>();
p.loadAll();
p.loadLeaderboard(); // independent — always fires regardless of loadAll TTL
});
}
@@ -274,7 +276,7 @@ class _ContributeScreenState extends State<ContributeScreen>
const SizedBox(height: 16),
// Leaderboard List
if (provider.isLoading && leaderboard.isEmpty)
if (provider.isLeaderboardLoading && leaderboard.isEmpty)
const Padding(
padding: EdgeInsets.symmetric(vertical: 60),
child: Center(child: CircularProgressIndicator(strokeWidth: 2)),