Skip to content

Commit a932631

Browse files
committed
fix(RevenueCatUI): reuse standalone state store across full state refreshes
1 parent 3925c0f commit a932631

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data

ui/revenuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/PaywallViewModel.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ internal class PaywallViewModelImpl(
211211

212212
// Shared across all screens of a workflow presentation so state-driven values survive screen navigation.
213213
private var currentWorkflowStateStore: PaywallStateStore? = null
214+
215+
// Reused across full state refreshes (e.g. color changes) of a standalone paywall so its state-driven values
216+
// are not lost. Tied to this ViewModel's lifetime, so it resets when the paywall is presented again.
217+
private var standaloneStateStore: PaywallStateStore? = null
214218
private var preWarmJob: Job? = null
215219
private var transitionIdCounter: Int = 0
216220

@@ -910,11 +914,14 @@ internal class PaywallViewModelImpl(
910914
"You do not have a current offering configured in the RevenueCat dashboard.",
911915
)
912916
} else {
917+
val stateStore = standaloneStateStore
918+
?: PaywallStateStore(emptyMap()).also { standaloneStateStore = it }
913919
_state.value = calculateState(
914920
currentOffering,
915921
_colorScheme.value,
916922
purchases.storefrontCountryCode,
917923
options.mode,
924+
stateStore = stateStore,
918925
)
919926
}
920927
}

0 commit comments

Comments
 (0)