Skip to content

fix: Initialize missing counters upon login#7448

Open
SISIR-REDDY wants to merge 1 commit into
openfoodfacts:developfrom
SISIR-REDDY:fix-7373-init-counters
Open

fix: Initialize missing counters upon login#7448
SISIR-REDDY wants to merge 1 commit into
openfoodfacts:developfrom
SISIR-REDDY:fix-7373-init-counters

Conversation

@SISIR-REDDY
Copy link
Copy Markdown

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.10%. Comparing base (4d9c7fc) to head (3de9763).
⚠️ Report is 1373 commits behind head on develop.

Files with missing lines Patch % Lines
...d_in/statistics_cards/app_bar_statistics_card.dart 0.00% 7 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@teolemon
Copy link
Copy Markdown
Member

teolemon commented Apr 9, 2026

@SISIR-REDDY we're short on reviewing power, so I requested a Copilot initial review meanwhile

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 initState post-frame check to detect missing cached counter values.
  • Automatically triggers _asyncLoad() to fetch and cache the counter when needed.

Comment on lines +46 to +52
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
final UserPreferences userPreferences = context.read<UserPreferences>();
final int? count = widget.lazyCounter.getLocalCount(userPreferences);
if (count == null) {
_asyncLoad();
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 💬 To discuss and validate

Development

Successfully merging this pull request may close these issues.

Counters not initialized upon connection

4 participants