({
title,
content,
movieUrl,
imgUrl = paywallImageUrl,
toPricingCode,
buttonText,
}: Omit<PaywallModalStore, "open">)
| 30 | * Also pre-load the paywall image |
| 31 | * */ |
| 32 | export function showPaywall({ |
| 33 | title, |
| 34 | content, |
| 35 | movieUrl, |
| 36 | imgUrl = paywallImageUrl, |
| 37 | toPricingCode, |
| 38 | buttonText, |
| 39 | }: Omit<PaywallModalStore, "open">) { |
| 40 | if (!buttonText) { |
| 41 | buttonText = t`Learn More`; |
| 42 | } |
| 43 | |
| 44 | // If there is no movie URL, we will preload the image |
| 45 | if (!movieUrl) { |
| 46 | // Pre-load the paywall image |
| 47 | const img = new Image(); |
| 48 | img.onload = open; |
| 49 | img.src = imgUrl; |
| 50 | } else { |
| 51 | open(); |
| 52 | } |
| 53 | |
| 54 | function open() { |
| 55 | usePaywallModalStore.setState({ |
| 56 | open: true, |
| 57 | title, |
| 58 | content, |
| 59 | movieUrl, |
| 60 | imgUrl, |
| 61 | toPricingCode, |
| 62 | buttonText, // Include buttonText in setState |
| 63 | }); |
| 64 | } |
| 65 | } |
no test coverage detected