From 76142c4bb7f98fbbd14b2dbd167a3c2a4fb58de4 Mon Sep 17 00:00:00 2001 From: majakomel Date: Mon, 23 Sep 2024 18:42:03 +0200 Subject: [PATCH] Enable iOS v2 testing --- components/v2/CTA.tsx | 1 + pages/v2/[linkId].tsx | 35 ++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/components/v2/CTA.tsx b/components/v2/CTA.tsx index 488745c..70f0b21 100644 --- a/components/v2/CTA.tsx +++ b/components/v2/CTA.tsx @@ -7,6 +7,7 @@ type CTAProps = { } const CTA = ({ linkTitle, deepLink }: CTAProps) => { + console.log('CTA deepLink', deepLink) const intl = useIntl() return (
diff --git a/pages/v2/[linkId].tsx b/pages/v2/[linkId].tsx index 57f7a3c..fe6527a 100644 --- a/pages/v2/[linkId].tsx +++ b/pages/v2/[linkId].tsx @@ -1,27 +1,30 @@ import OONIRunHero from 'components/OONIRunHero' import OONIRunHeroMinimal from 'components/OONIRunHeroMinimal' -import CTA from 'components/v2/CTA' +// import CTA from 'components/v2/CTA' import DescriptorView from 'components/v2/DescriptorView' import MetaTags from 'components/v2/MetaTags' import PublicDescriptorView from 'components/v2/PublicDescriptorView' import mobileApp from 'config/mobileApp' import { getRunLink } from 'lib/api' import type { GetServerSideProps } from 'next' +import dynamic from 'next/dynamic' import type { ParsedUrlQuery } from 'node:querystring' +import { useMemo } from 'react' import { useIntl } from 'react-intl' import { getIntentURIv2, getUniversalQuery } from 'utils/links' import OONI404 from '/public/static/images/OONI_404.svg' -const useragent = require('useragent/index.js') +const CTA = dynamic(() => import('components/v2/CTA'), { + ssr: false, +}) -const installLink = 'https://ooni.org/install' +const useragent = require('useragent/index.js') type Props = { deepLink: string iOSDeepLink: string withWindowLocation: boolean storeLink: string - installLink: string userAgent: string universalLink: string title: string @@ -112,7 +115,6 @@ export const getServerSideProps: GetServerSideProps = async ({ iOSDeepLink, withWindowLocation, storeLink, - installLink, userAgent: JSON.stringify(ua), universalLink, title, @@ -131,7 +133,6 @@ const Nettest = ({ iOSDeepLink, withWindowLocation, storeLink, - installLink, universalLink, title, description, @@ -140,13 +141,17 @@ const Nettest = ({ error, }: Props) => { const intl = useIntl() - const isIOS = - typeof window !== 'undefined' // TODO: remove after iOS testing - ? JSON.parse(userAgent)?.os?.family === 'iOS' && // TODO: remove after iOS testing - window.location.hostname !== 'run.test.ooni.org' // TODO: remove after iOS testing - : JSON.parse(userAgent)?.os?.family === 'iOS' - const displayDeepLink = isIOS ? iOSDeepLink : deepLink + const isIOS = false + // typeof window !== 'undefined' // TODO: remove after iOS testing + // ? JSON.parse(userAgent)?.os?.family === 'iOS' && // TODO: remove after iOS testing + // window.location.hostname !== 'run.test.ooni.org' // TODO: remove after iOS testing + // : JSON.parse(userAgent)?.os?.family === 'iOS' + const displayDeepLink = useMemo( + () => (isIOS ? iOSDeepLink : deepLink), + [isIOS, deepLink, iOSDeepLink], + ) console.log('isIOS', isIOS) + console.log('displayDeepLink', displayDeepLink) const windowScript = `window.onload = function() { document.getElementById('l').src = '${displayDeepLink}'; setTimeout(function() { @@ -182,11 +187,7 @@ const Nettest = ({ ) : (
- +