diff --git a/adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallView.kt b/adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallView.kt index 6c9372c..db16fff 100644 --- a/adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallView.kt +++ b/adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallView.kt @@ -36,6 +36,8 @@ public class AdaptyPaywallView @JvmOverloads constructor( defStyleAttr: Int = 0, ) : AbstractComposeView(context, attrs, defStyleAttr) { + private val instanceKey: String = UUID.randomUUID().toString() + private val viewModel: PaywallViewModel? by lazy { val viewModelStoreOwner = findViewTreeViewModelStoreOwner() ?: run { @@ -43,12 +45,12 @@ public class AdaptyPaywallView @JvmOverloads constructor( return@lazy null } PaywallViewModelArgs.create( - "${UUID.randomUUID().toString().hashCode()}", + "${instanceKey.hashCode()}", null, context.getCurrentLocale(), )?.let { args -> val factory = PaywallViewModelFactory(args) - ViewModelProvider(viewModelStoreOwner, factory)[PaywallViewModel::class.java] + ViewModelProvider(viewModelStoreOwner, factory)[instanceKey, PaywallViewModel::class.java] } } diff --git a/adapty-ui/src/main/java/com/adapty/ui/internal/text/TextResolver.kt b/adapty-ui/src/main/java/com/adapty/ui/internal/text/TextResolver.kt index d86528e..b4e0695 100644 --- a/adapty-ui/src/main/java/com/adapty/ui/internal/text/TextResolver.kt +++ b/adapty-ui/src/main/java/com/adapty/ui/internal/text/TextResolver.kt @@ -52,8 +52,8 @@ internal class TextResolver( val desiredProductId = stringId.productId?.takeIf { it.isNotEmpty() } ?: state[getProductGroupKey(stringId.productGroupId)] as? String val desiredLocalText = if (!desiredProductId.isNullOrEmpty()) { - val product = products[desiredProductId] ?: return StringWrapper.EMPTY - val paymentModeStr = when(product.firstDiscountOfferOrNull()?.paymentMode) { + val product = products[desiredProductId] + val paymentModeStr = when(product?.firstDiscountOfferOrNull()?.paymentMode) { PaymentMode.FREE_TRIAL -> "free_trial" PaymentMode.PAY_AS_YOU_GO -> "pay_as_you_go" PaymentMode.PAY_UPFRONT -> "pay_up_front"