fix: Initialize missing counters upon login#7448
Conversation
SISIR-REDDY
commented
Mar 15, 2026
- Fixes: Counters not initialized upon connection #7373\n\n### What\n- Fetches the counter values immediately on connection if not cached.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7448 +/- ##
==========================================
- Coverage 9.54% 9.10% -0.45%
==========================================
Files 325 625 +300
Lines 16411 36645 +20234
==========================================
+ Hits 1567 3337 +1770
- Misses 14844 33308 +18464 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@SISIR-REDDY we're short on reviewing power, so I requested a Copilot initial review meanwhile |
There was a problem hiding this comment.
Pull request overview
Ensures the Community tab statistics counters are initialized right after login by triggering a server fetch when no cached value exists (Fixes #7373).
Changes:
- Added an
initStatepost-frame check to detect missing cached counter values. - Automatically triggers
_asyncLoad()to fetch and cache the counter when needed.
| WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| if (mounted) { | ||
| final UserPreferences userPreferences = context.read<UserPreferences>(); | ||
| final int? count = widget.lazyCounter.getLocalCount(userPreferences); | ||
| if (count == null) { | ||
| _asyncLoad(); | ||
| } |
There was a problem hiding this comment.
The _asyncLoad() call inside the post-frame callback is a fire-and-forget Future. If the project’s lints include unawaited_futures (analysis runs with --fatal-infos/--fatal-warnings), this may fail analysis. Consider wrapping the call in unawaited(_asyncLoad()); (and add import 'dart:async';) to make the intent explicit and satisfy the lint rules.