Skip to content

Reload Customer Center after a successful restore#2203

Merged
vegaro merged 7 commits into
mainfrom
cc-375-customer-center-not-refreshing-after-successful-restore
Mar 4, 2025
Merged

Reload Customer Center after a successful restore#2203
vegaro merged 7 commits into
mainfrom
cc-375-customer-center-not-refreshing-after-successful-restore

Conversation

@vegaro

@vegaro vegaro commented Feb 28, 2025

Copy link
Copy Markdown
Member

Reload the Customer Center after a successful restore

@vegaro

vegaro commented Feb 28, 2025

Copy link
Copy Markdown
Member Author

I've noticed an issue here, since I am updating the state twice. going back to draft

@vegaro vegaro marked this pull request as draft February 28, 2025 14:18
@codecov

codecov Bot commented Feb 28, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.47%. Comparing base (0188643) to head (1f432bc).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2203   +/-   ##
=======================================
  Coverage   80.47%   80.47%           
=======================================
  Files         277      277           
  Lines        9461     9461           
  Branches     1336     1336           
=======================================
  Hits         7614     7614           
  Misses       1287     1287           
  Partials      560      560           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vegaro vegaro marked this pull request as ready for review February 28, 2025 15:07
@emerge-tools

emerge-tools Bot commented Feb 28, 2025

Copy link
Copy Markdown

📸 Snapshot Test

5 modified, 240 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
TestPurchasesUIAndroidCompatibility
com.revenuecat.testpurchasesuiandroidcompatibility
0 0 5 0 240 0 ✅ Approved

🛸 Powered by Emerge Tools

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking good! left some comments but I wouldn't block the PR. Lmk what you think though!

override suspend fun dismissRestoreDialog(restored: Boolean) {
if (restored) {
// Reload customer center data to refresh the UI with the latest information
loadCustomerCenter()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm does it make sense to just do this always after dismissing the restore dialog, even if there were no purchases? I don't think it would be a huge deal and would simplify the code but not sure if there are reasons for it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

you know what? I like it. I wasn't a fan of this restored boolean but didn't find an alternative. If someone is opening the restore dialog anyways it would be good to reload just in case.

private fun PurchasesRecoveredDialog(
localization: CustomerCenterConfigData.Localization,
onDismiss: () -> Unit,
onDismiss: (recovered: Boolean) -> Unit,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This brought to mind some conversations we've had recently for paywalls, about whether to display our own restore dialogs in paywalls or leave it to the developer. While there are some cases we might want to display them from our side, currently we're letting the developer handle these dialogs on their side so they can customize any way they like. I think CustomerCenter doesn't require that much customization so it makes sense to keep it like this I think...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, that's an interesting point, I like it. Fwiw, we are simplifying the dialog and removing the initial confirmation, but that's in another task.

As well, we are going to be creating more powerful "paths" that just trigger a callback, for custom actions. That custom restore could be one of these.

},
onRestore = onRestore,
)
RestorePurchasesState.PURCHASES_RECOVERED -> PurchasesRecoveredDialog(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not from this PR but I was looking at the logic behind knowing whether purchases were recovered. It seems we just check if there are any active subs or any non subs at all... I do wonder if we can consider that purchases were recovered in that case, since those might be purchases from other stores, and nothing was recovered from the current store for example...

I guess to get this properly, we would need some sort of diff between the customer info before/after the restore, but that's a bit trickier... Nothing to do in this PR, but something to consider about the behavior here.

@vegaro vegaro enabled auto-merge (squash) March 4, 2025 15:40
vegaro added 2 commits March 4, 2025 16:40
…successful-restore

# Conflicts:
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/customercenter/data/CustomerCenterViewModelTests.kt
@vegaro vegaro merged commit 82a9f29 into main Mar 4, 2025
@vegaro vegaro deleted the cc-375-customer-center-not-refreshing-after-successful-restore branch March 4, 2025 18:03
tonidero added a commit that referenced this pull request Mar 6, 2025
**This is an automatic release.**

## RevenueCat SDK
### ✨ New Features
* Add `hasPaywall` property to `Offering` (#2212) via Antonio Pallares
(@ajpallares)
### 🐞 Bugfixes
* Fix empty options in NoActive subscriptions screen (#2168) via Cesar
de la Vega (@vegaro)

## RevenueCatUI SDK
### Customer Center
#### ✨ New Features
* Create `CustomerCenterListener` (#2199) via Cesar de la Vega (@vegaro)
#### 🐞 Bugfixes
* Reload Customer Center after a successful restore (#2203) via Cesar de
la Vega (@vegaro)
* Fixes CustomerCenter state not refreshing when reopening (#2202) via
Cesar de la Vega (@vegaro)

### 🔄 Other Changes
* Improves PaywallsTester multi-API-key support (#2218) via JayShortway
(@JayShortway)
* [EXTERNAL] Bump Emerge Gradle Plugin and Snaphsots version (#2211) via
@runningcode (#2217) via JayShortway (@JayShortway)
* [AUTOMATIC][Paywalls V2] Updates Compose previews of all templates
(#2207) via RevenueCat Git Bot (@RCGitBot)
* [Paywalls V2] Enables template previews again (#2215) via JayShortway
(@JayShortway)
* Adds support for switching between 2 API keys to PaywallsTester
(#2213) via JayShortway (@JayShortway)
* Adds a `LocalPreviewImageLoader` `CompositionLocal`. (#2201) via
JayShortway (@JayShortway)
* Logs from RevenueCatUI are now tagged with `[Purchases]` too. (#2206)
via JayShortway (@JayShortway)
* [Paywalls V2] Ignores template previews for now. (#2209) via
JayShortway (@JayShortway)
* [Paywalls V2] Some more template previews optimizations (#2208) via
JayShortway (@JayShortway)
* chore: Delete key from customer center survey event (#2204) via
Facundo Menzella (@facumenzella)
* [Paywalls V2] Extract ImageLoader to use a single one (#2146) via Toni
Rico (@tonidero)
* [Paywalls V2] Adds progress indicator to buttons (#2198) via
JayShortway (@JayShortway)
* Avoids triggering "unscheduled" workflows when triggering workflows
via the CircleCI API (#2200) via JayShortway (@JayShortway)
* [Paywalls V2] Adds a note on publishing to the missing paywall error.
(#2193) via JayShortway (@JayShortway)
* Adds X-Kotlin-Version header. (#2197) via JayShortway (@JayShortway)
* [Paywalls V2] Adds docs on ignored arguments for Paywalls V2 in more
places. (#2195) via JayShortway (@JayShortway)
* chore: Add backend integration test for events (#2189) via Facundo
Menzella (@facumenzella)
* [Paywalls V2] Adds CI job to update template previews (#2192) via
JayShortway (@JayShortway)

---------

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Co-authored-by: Cesar de la Vega <cesarvegaro@gmail.com>
Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants