Skip to content

fix(subscriptions): refresh profile subscription section after purchase - #73

Merged
CowboyGH merged 2 commits into
developfrom
fix/profile-subscription-refresh-after-purchase
Jun 13, 2026
Merged

CowboyGH merged 2 commits into
developfrom
fix/profile-subscription-refresh-after-purchase

Conversation

@CowboyGH

@CowboyGH CowboyGH commented Jun 13, 2026 •

Copy link
Copy Markdown
Owner

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 of context.go(profilePath).
  • SubscriptionsCatalogPage: pushes details with push<bool>; if true comes back, pops itself with true to propagate further.
  • ProfileSubscriptionSectionWidget: pushes catalog/details with push<bool>; on true, calls ProfileSubscriptionCubit.load() to refresh.
  • No new cross-feature coupling: ProfileSubscriptionCubit is no longer a DI singleton, subscriptions no longer imports anything from profile.

How to test

  1. Profile → Subscriptions catalog → buy a subscription → returns to Profile, subscription section shows the new active subscription.
  2. Profile (with active subscription) → tap the subscription card directly (skip catalog) → buy/renew → returns to Profile, section refreshed.
  3. Cancel the purchase dialog or back out at any step → no unwanted reload, navigation unchanged.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR consolidates ProfileSubscriptionCubit instantiation into the DI container, moving it from ad-hoc local construction in presentation pages. The DI setup registers the cubit as a lazy singleton with ProfileRepository and SubscriptionsRepository, then ProfilePageBuilder retrieves it via BlocProvider.value instead of creating it directly. A new side-effect in SubscriptionsDetailsPage reloads the subscription state via the DI-provided cubit after successful payment, ensuring data consistency across the app.

Suggested labels

area: logic

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A cubit once scattered, now gathered in one place,
From DI's container, it runs the profile race.
When payments succeed, the subscriptions align,
Centralized wisdom—now state will shine! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: registering ProfileSubscriptionCubit in DI and triggering a refresh of the profile subscription section after a successful subscription purchase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/profile-subscription-refresh-after-purchase

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 63ed9f6 and f7e0e42.

📒 Files selected for processing (3)
  • lib/core/di/di.dart
  • lib/features/profile/presentation/pages/profile_page_builder.dart
  • lib/features/subscriptions/presentation/pages/subscriptions_details_page.dart

Comment thread lib/core/di/di.dart Outdated
Comment thread lib/features/profile/presentation/pages/profile_page_builder.dart Outdated
@CowboyGH CowboyGH self-assigned this Jun 13, 2026
@CowboyGH CowboyGH added area: ui/ux Widgets, layout, animations, or design type: bug Something isn't working area: logic State management and business logic labels Jun 13, 2026
@CowboyGH
CowboyGH merged commit 0818961 into develop Jun 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: logic State management and business logic area: ui/ux Widgets, layout, animations, or design type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant