From 336e9cd7b7e492478c936f8096a9aa6a9904d8b0 Mon Sep 17 00:00:00 2001 From: Michael Helfer Date: Wed, 24 Apr 2024 23:46:51 -0500 Subject: [PATCH] if at first you dont succeed --- src/components/Redirect.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/Redirect.tsx b/src/components/Redirect.tsx index 5a0ab6e..857c901 100644 --- a/src/components/Redirect.tsx +++ b/src/components/Redirect.tsx @@ -2,16 +2,19 @@ import React, { useEffect, useState } from 'react'; import { useLocation } from 'react-router-dom'; import GooglePlayButton from '@theme/GooglePlayButton'; import AppStoreButton from '@theme/AppStoreButton'; +import { useHistory } from 'react-router-dom'; const Redirect: React.FC = () => { - const [display, setDisplay] = useState('none'); - const location = useLocation(); - const params = new URLSearchParams(location.search); - const promoter = params.get('x') || 'threetenlabs'; - const utmMedium = params.has('x') ? 'influencer' : 'website'; + const [display, setDisplay] = useState('none'); + const location = useLocation(); + const history = useHistory(); + const params = new URLSearchParams(location.search); + const promoter = params.get('x') || 'threetenlabs'; + const utmMedium = params.has('x') ? 'influencer' : 'website'; + + const iOSUrl = `https://apps.apple.com/us/app/y-a-s-s/id6472488148?ct=2024install&pt=${promoter}`; + const androidUrl = `https://play.google.com/store/apps/details?id=com.threetenlabs.spidersolitaire&utm_source=threetenlabswebsite&utm_medium=${utmMedium}&utm_campaign=2024install&utm_content=${promoter}`; - const iOSUrl = `https://apps.apple.com/us/app/y-a-s-s/id6472488148?ct=2024install&pt=${promoter}`; - const androidUrl = `https://play.google.com/store/apps/details?id=com.threetenlabs.spidersolitaire&utm_source=threetenlabswebsite&utm_medium=${utmMedium}&utm_campaign=2024install&utm_content=${promoter}`; useEffect(() => { var ua = navigator.userAgent.toLowerCase(); @@ -19,9 +22,9 @@ const Redirect: React.FC = () => { var isiOS = /iPad|iPhone|iPod/.test(ua); if (isiOS) { - window.location.href = iOSUrl; + history.push(iOSUrl); } else if (isAndroid) { - window.location.href = androidUrl; + history.push(androidUrl); } else { setDisplay('flex'); }