Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Paywalls V2] Selects the correct package by default #2043

Draft
wants to merge 49 commits into
base: main
Choose a base branch
from

Conversation

JayShortway
Copy link
Member

Description

The backend sends the isSelectedByDefault property along with any package components. Thus far this was ignored. This PR fixes that.

Note

This is a draft, because it is not compatible with multi-tier, and there's some ongoing discussion on possibly changing the network response. Best to wait for that to flesh out.

…actions

# Conflicts:
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/PaywallActionTests.kt
# Conflicts:
#	purchases/src/main/kotlin/com/revenuecat/purchases/paywalls/components/properties/ColorInfo.kt
…actions

# Conflicts:
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/style/StyleFactory.kt
# Conflicts:
#	ui/revenuecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/components/PaywallActionTests.kt
# Conflicts:
#	ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/InternalPaywall.kt
Comment on lines +127 to +131
// Find the first PackageComponentStyle which has isSelectedByDefault equal to true.
val predicate: (ComponentStyle) -> Boolean = { it is PackageComponentStyle && it.isSelectedByDefault }
val initialSelectedPackage = (stack.firstOrNull(predicate) ?: stickyFooter?.firstOrNull(predicate))
?.let { it as PackageComponentStyle? }
?.rcPackage
Copy link
Member Author

Choose a reason for hiding this comment

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

Two reasons why this is not great:

  • It traverses the tree again, while StyleFactory already did. Best to do it in 1 pass.
  • It is not compatible with multi-tier.

* allows us to assert this behavior from a higher level.
*/
@Test
fun `Should select the correct package by default`(): Unit = with(composeTestRule) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is what this PR fixes.

Base automatically changed from pw2-package-selection-variables to main January 13, 2025 15:44
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