PE-9103: Refresh balance after Turbo topup from profile dropdown#2163
Conversation
The profile card's topup button was not passing an onSuccess callback to showTurboTopupModal, so no balance refresh happened after a successful topup. Turbo credits update automatically on next dropdown open (fresh TurboBalanceCubit), but the AR balance was stale if the user paid with AR. Now passes onSuccess to call profileCubit.refreshBalance() after successful topup, matching the pattern already used in payment_method_selector_widget.dart. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds a balance refresh callback after successful Turbo top-up in the profile card, and includes two unrelated minor refactors: converting ChangesTurbo Top-up Balance Refresh
Unrelated Component Cleanups
Estimated code review effort: 1 (Trivial) | ~5 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ProfileCard
participant TurboTopupModal
participant ProfileCubit
User->>ProfileCard: Tap "+" on Credits
ProfileCard->>TurboTopupModal: showTurboTopupModal(context, onSuccess)
TurboTopupModal-->>ProfileCard: Top-up success
ProfileCard->>ProfileCard: Check context.mounted
ProfileCard->>ProfileCubit: refreshBalance()
ProfileCubit-->>ProfileCard: Updated balance
Related Issues: None specified Related PRs: None specified Suggested labels: None specified Suggested reviewers: None specified Poem: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/ardrive_ui/storybook/lib/src/table.dart (1)
123-128: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer a
constconstructor over suppressing the lint.Since
IndexedItemnow has aconstconstructor and all ofFile's fields arefinal, theFileconstructor itself can beconst, satisfyingprefer_const_constructors_in_immutableswithout the ignore comment. The runtime call sites (e.g.name: 'Item $i') simply won't useconst, but the declaration can still beconst.♻️ Proposed refactor
- // ignore: prefer_const_constructors_in_immutables - File({ + const File({ required this.createdAt, required this.name, required this.size, }) : super(0);Based on learnings: "prefer using const constructors for object instantiations whenever the constructor is declared as const and all arguments are compile-time constants."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ardrive_ui/storybook/lib/src/table.dart` around lines 123 - 128, The File constructor in table.dart is suppressing prefer_const_constructors_in_immutables even though it can be const because IndexedItem has a const constructor and all File fields are final. Remove the ignore comment and declare File as a const constructor so call sites can still choose non-const instantiation when needed. Use the File and IndexedItem constructors to locate the change.Source: Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/ardrive_ui/storybook/lib/src/table.dart`:
- Around line 123-128: The File constructor in table.dart is suppressing
prefer_const_constructors_in_immutables even though it can be const because
IndexedItem has a const constructor and all File fields are final. Remove the
ignore comment and declare File as a const constructor so call sites can still
choose non-const instantiation when needed. Use the File and IndexedItem
constructors to locate the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 17941c9b-5b43-4f70-a4ea-a40986a01b22
📒 Files selected for processing (3)
lib/components/profile_card.dartpackages/ardrive_ui/lib/src/components/data_table/data_table.dartpackages/ardrive_ui/storybook/lib/src/table.dart
EquatableMixin is deprecated in favor of using Equatable directly. Changed IndexedItem from `with EquatableMixin` to `extends Equatable` with const constructor. This fixes the CI analyze failure in the ardrive_ui package. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3999df7 to
847f00b
Compare
|
Visit the preview URL for this PR (updated for commit 847f00b): https://ardrive-web--pr2163-pe-9103-turbo-balanc-wcrzk1og.web.app (expires Sun, 12 Jul 2026 20:53:40 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: a224ebaee2f0939e7665e7630e7d3d6cd7d0f8b0 |
Summary
When a user tops up Turbo credits from the profile dropdown, no balance refresh was triggered after payment succeeded. The
showTurboTopupModal()call was missing theonSuccesscallback.TurboBalanceCubitis created fresh with..getBalance()each time the dropdown opensprofileCubit.refreshBalance()via theonSuccesscallbackThis matches the pattern already used in
payment_method_selector_widget.dart(upload flow topup) whereonSuccessis passed.Note: if the Turbo payment service has a server-side delay in crediting the account, the user may need to reopen the dropdown after a few seconds to see the updated credits. This is a server-side timing issue, not a client bug.
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit