Skip to content

fix(trades): remove spurious badge dot and pending status flash - #86

Merged
grunch merged 1 commit into
mainfrom
fix/trades-badge-and-status-flash
Apr 3, 2026
Merged

fix(trades): remove spurious badge dot and pending status flash#86
grunch merged 1 commit into
mainfrom
fix/trades-badge-and-status-flash

Conversation

@grunch

@grunch grunch commented Apr 3, 2026

Copy link
Copy Markdown
Member

Badge: change notification count logic from 'unseen if no prior snapshot' to 'unseen only if status changed from a known prior state'. With an empty _lastSeenStatusesProvider on app start every non-terminal trade counted as unseen, causing the red dot to appear before the user had missed anything.

Status flash: remove the immediate yield of OrderStatus.pending from tradeStatusProvider. The pending yield was overriding the correct DB-stored status for 2 s until the first real getOrder() fetch completed. TradesListItem already falls back to trade.status (DB value) while the stream is in loading state, so removing the bogus yield shows the correct status from the start.

Summary by CodeRabbit

  • Bug Fixes

    • Notification badge counts in the order book now more accurately reflect unread and changed trades.
    • Trade status updates are retrieved more reliably with improved initial loading behavior.
  • Performance Improvements

    • Trade status polling optimized to fetch initial updates immediately, followed by efficient interval-based refreshes.

Badge: change notification count logic from 'unseen if no prior snapshot'
to 'unseen only if status changed from a known prior state'. With an empty
_lastSeenStatusesProvider on app start every non-terminal trade counted as
unseen, causing the red dot to appear before the user had missed anything.

Status flash: remove the immediate yield of OrderStatus.pending from
tradeStatusProvider. The pending yield was overriding the correct DB-stored
status for 2 s until the first real getOrder() fetch completed. TradesListItem
already falls back to trade.status (DB value) while the stream is in loading
state, so removing the bogus yield shows the correct status from the start.
@coderabbitai

coderabbitai Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

This PR refines polling behavior in the trade status provider by removing an immediate pending status fallback and adjusting fetch timing, while tightening the badge-count logic to exclude trades lacking a prior seen-status snapshot.

Changes

Cohort / File(s) Summary
Trade Status Polling
lib/features/order/providers/trade_state_provider.dart
Removed immediate OrderStatus.pending yield fallback; restructured polling to fetch immediately on first call before applying 2-second delay between subsequent polls. Updated documentation to guide callers to use AsyncValue.whenOrNull for loading states.
Order Book Badge Count
lib/features/trades/providers/trades_providers.dart
Narrowed badge-count eligibility criteria from `seen == null

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through polling streams so bright,
Removing fallbacks, timing feels just right—
With badges counted clean and true,
Only seen trades make the queue! 🌿✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main fixes: removing the spurious badge dot and preventing the pending status flash, matching the documented objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/trades-badge-and-status-flash

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@grunch
grunch merged commit 3512ec1 into main Apr 3, 2026
1 check was pending
@grunch
grunch deleted the fix/trades-badge-and-status-flash branch April 3, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant