Skip to content

Commit

Permalink
Fix multiple paywalls display issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tonidero committed Sep 24, 2024
1 parent a62da95 commit 1bbdd1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ internal fun getPaywallViewModel(
): PaywallViewModel {
val applicationContext = LocalContext.current.applicationContext
val viewModel = viewModel<PaywallViewModelImpl>(
key = options.dataHash,
factory = PaywallViewModelFactory(
applicationContext.toResourceProvider(),
options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ data class PaywallOptions internal constructor(
dismissRequest = builder.dismissRequest,
)

internal val dataHash: String = run {
val hashMultiplier = 31
var result = offeringSelection.offeringIdentifier.hashCode()
result = hashMultiplier * result + shouldDisplayDismissButton.hashCode()
result = hashMultiplier * result + mode.hashCode()
result.toString()
}

class Builder(
internal val dismissRequest: () -> Unit,
) {
Expand Down

0 comments on commit 1bbdd1d

Please sign in to comment.