| 78 | wasOnPost.current = isPostUrl(asPathRef.current ?? ''); |
| 79 | |
| 80 | const onRouteChange = (url: string) => { |
| 81 | const onPost = isPostUrl(url); |
| 82 | const leftPost = wasOnPost.current && !onPost; |
| 83 | wasOnPost.current = onPost; |
| 84 | |
| 85 | if ( |
| 86 | !leftPost || |
| 87 | hasAsked.current || |
| 88 | modalRef.current || |
| 89 | isPausedRef.current || |
| 90 | !marketingCtaRef.current |
| 91 | ) { |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | hasAsked.current = true; |
| 96 | const { current } = marketingCtaRef; |
| 97 | if (current.variant === MarketingCtaVariant.AppStoreReviewPlus) { |
| 98 | openModal({ |
| 99 | type: LazyModal.AppStoreReviewPlus, |
| 100 | props: { marketingCta: current }, |
| 101 | }); |
| 102 | return; |
| 103 | } |
| 104 | openModal({ |
| 105 | type: LazyModal.AppStoreReview, |
| 106 | props: { marketingCta: current }, |
| 107 | }); |
| 108 | }; |
| 109 | |
| 110 | events.on('routeChangeComplete', onRouteChange); |
| 111 | |