Skip to content

Avoid recreating purchases same config#1866

Closed
tonidero wants to merge 3 commits into
mainfrom
avoid-recreating-purchases-same-config
Closed

Avoid recreating purchases same config#1866
tonidero wants to merge 3 commits into
mainfrom
avoid-recreating-purchases-same-config

Conversation

@tonidero

@tonidero tonidero commented Oct 4, 2024

Copy link
Copy Markdown
Contributor

Description

This came from a conversation in Slack. I think we can limit the amount of multiple configuration issues if we don't reconfigure the SDK with the same parameters that were originally passed. I don't think there should be any use cases for that in any case? Keeping on hold to get feedback

@codecov

codecov Bot commented Oct 4, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 73.33333% with 8 lines in your changes missing coverage. Please review.

Project coverage is 82.35%. Comparing base (26074e4) to head (e8cd5f1).

Files with missing lines Patch % Lines
...com/revenuecat/purchases/PurchasesConfiguration.kt 71.42% 0 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1866      +/-   ##
==========================================
- Coverage   82.37%   82.35%   -0.03%     
==========================================
  Files         225      225              
  Lines        7900     7929      +29     
  Branches     1104     1119      +15     
==========================================
+ Hits         6508     6530      +22     
+ Misses        953      952       -1     
- Partials      439      447       +8     

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


init {
this.context = builder.context
this.context = builder.context.applicationContext

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I noticed we could potentially be leaking an activity if the developer gave us the activity context and we hold a reference to this object. So I changed it here so we only hold the application context, which is the one developers should normally give us.

tonidero added a commit that referenced this pull request Oct 8, 2024
…matically (#1872)

### Description
In here we store the latest known state for `Purchases` so we can
reconfigure when displaying the `PaywallActivity` and the SDK is not
configured. This may happen if the app is killed while displaying the
`PaywallActivity`, the developer is not configuring in the application
but on an activity and the user returns through the app through the
recent apps menu.

Additionally, it includes the changes from #1866 so we avoid
reconfiguring the SDK if the configuration parameters are the same.
@tonidero

tonidero commented Oct 8, 2024

Copy link
Copy Markdown
Contributor Author

Closing in favor of #1872

@tonidero tonidero closed this Oct 8, 2024
@tonidero tonidero deleted the avoid-recreating-purchases-same-config branch October 8, 2024 15:56
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.

1 participant