Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions adapty-ui/src/main/java/com/adapty/ui/AdaptyPaywallView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,21 @@ 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 {
log(ERROR) { "$LOG_PREFIX AdaptyPaywallView (${hashCode()}) rendering error: No ViewModelStoreOwner found" }
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]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down