Potential fix for variable not rendering until paywall interaction#2948
Draft
Potential fix for variable not rendering until paywall interaction#2948
Conversation
Contributor
Author
|
Note This needs to be tested well. I need to replicate the issue and test this in several scenarios |
Generated by 🚫 Danger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
purchases-iosand hybridsMotivation
Price variables such as
{{ product.price_per_week }}were displayed as literal text on initial paywall render, then correctly resolved after user interaction (e.g., tapping a tab, switch, or package).Description
Root Cause
A logic inconsistency in
PaywallState.ktwhereselectedTabIndexandinitialSelectedPackageused different null-handling strategies for theinitialSelectedTabIndexparameter.The Problem
When
initialSelectedTabIndexisnull(which occurs when aTabsComponenthas nodefaultTabIdset):selectedTabIndex0?: 0initialSelectedTabIndex?.let { ... }null?.letshort-circuits on null receiverinitialSelectedPackagenullselectedPackageByTab[0]has a valid packageImpact
selectedPackageinitialized tonullselectedPackageInfobecomesnullTextComponentState.applicablePackagebecomesnullTextComponentView.rememberProcessedText(){{ product.price_per_week }}is displayedAfter user interaction,
update()is called with proper fallback logic that finds the package, triggering recomposition and correct variable processing.Fix
File:
ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/PaywallState.ktBefore:
After:
This ensures the package lookup uses
selectedTabIndex(which already defaults to0) instead of relying on the nullableinitialSelectedTabIndex.Affected Scenarios
Paywalls where:
TabsComponentexists without an explicitdefaultTabIdPackageComponentselectedPackageProvider()for package context