fix(subscriptions): refresh profile subscription section after purchase - #73
Conversation
📝 WalkthroughWalkthroughThis PR consolidates Suggested labels
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
Actionable comments posted: 2
🤖 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.
Inline comments:
In `@lib/core/di/di.dart`:
- Around line 174-180: ProfileSubscriptionCubit is registered as an app-lifetime
singleton via registerLazySingleton and its load() leaves previous
activeSubscription/item populated, causing stale UI; modify the cubit to add a
public reset() method that sets isLoading=false, failure=null and nulls
activeSubscription and item (or recreate the singleton instead), then call that
reset() on the auth boundary (e.g., in the logout/sign-out flow) and/or
immediately before using BlocProvider.value(... di<ProfileSubscriptionCubit>()
..load()) so the cubit state is cleared before load() runs; update dispose
handling if you choose recreation to ensure close() is still called.
In `@lib/features/profile/presentation/pages/profile_page_builder.dart`:
- Around line 67-69: The build currently calls
di<ProfileSubscriptionCubit>()..load() inside ProfilePageBuilder.build via
BlocProvider.value which triggers loads on every rebuild; remove the side-effect
from the build by changing the BlocProvider.value to just provide
di<ProfileSubscriptionCubit>() (i.e., BlocProvider.value(value:
di<ProfileSubscriptionCubit>()) ) and invoke ProfileSubscriptionCubit.load()
once during the page lifecycle instead — for example, convert ProfilePageBuilder
to a StatefulWidget and call di<ProfileSubscriptionCubit>().load() in initState,
or call di<ProfileSubscriptionCubit>().load() at route entry before pushing the
page.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 521f1f7f-8fd8-4e9c-9e9c-3646971c04f6
📒 Files selected for processing (3)
lib/core/di/di.dartlib/features/profile/presentation/pages/profile_page_builder.dartlib/features/subscriptions/presentation/pages/subscriptions_details_page.dart
Why
After a successful subscription purchase, the user is redirected back to Profile, but the subscription section stayed stale because no reload was triggered.
What
SubscriptionsDetailsPage: on successful purchase,context.pop(true)instead ofcontext.go(profilePath).SubscriptionsCatalogPage: pushes details withpush<bool>; iftruecomes back, pops itself withtrueto propagate further.ProfileSubscriptionSectionWidget: pushes catalog/details withpush<bool>; ontrue, callsProfileSubscriptionCubit.load()to refresh.ProfileSubscriptionCubitis no longer a DI singleton,subscriptionsno longer imports anything fromprofile.How to test