feat: redirect /address links to the wallet download landing page or app store (#7210)

This commit is contained in:
Nate Wienert 2023-09-08 08:33:21 -10:00 committed by GitHub
parent 16cefb9cdb
commit fdb9d8a8c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

@ -6,7 +6,7 @@ import TopLevelModals from 'components/TopLevelModals'
import { useFeatureFlagsIsLoaded } from 'featureFlags'
import { useAtom } from 'jotai'
import { useBag } from 'nft/hooks/useBag'
import { lazy, Suspense, useEffect, useMemo, useState } from 'react'
import { lazy, Suspense, useEffect, useLayoutEffect, useMemo, useState } from 'react'
import { Navigate, Route, Routes, useLocation, useSearchParams } from 'react-router-dom'
import { shouldDisableNFTRoutesAtom } from 'state/application/atoms'
import { useRouterPreference } from 'state/user/hooks'
@ -23,11 +23,11 @@ import { getCLS, getFCP, getFID, getLCP, Metric } from 'web-vitals'
import { useAnalyticsReporter } from '../components/analytics'
import ErrorBoundary from '../components/ErrorBoundary'
import { PageTabs } from '../components/NavBar'
import NavBar from '../components/NavBar'
import NavBar, { PageTabs } from '../components/NavBar'
import Polling from '../components/Polling'
import Popups from '../components/Popups'
import DarkModeQueryParamReader from '../theme/components/DarkModeQueryParamReader'
import { getDownloadAppLink } from '../utils/openDownloadApp'
import AddLiquidity from './AddLiquidity'
import { RedirectDuplicateTokenIds } from './AddLiquidity/redirects'
import { RedirectDuplicateTokenIdsV2 } from './AddLiquidityV2/redirects'
@ -188,6 +188,18 @@ export default function App() {
[account]
)
// redirect address to landing pages until implemented
const shouldRedirectToAppInstall = pathname?.startsWith('/address/')
useLayoutEffect(() => {
if (shouldRedirectToAppInstall) {
window.location.href = getDownloadAppLink()
}
}, [shouldRedirectToAppInstall])
if (shouldRedirectToAppInstall) {
return null
}
return (
<ErrorBoundary>
<DarkModeQueryParamReader />

@ -36,7 +36,7 @@ export function openDownloadApp(options: OpenDownloadAppOptions = defaultDownloa
}
// if you need this by itself can add export, not used externally for now
const getDownloadAppLink = (options: OpenDownloadAppOptions = defaultDownloadAppOptions) =>
export const getDownloadAppLink = (options: OpenDownloadAppOptions = defaultDownloadAppOptions) =>
isIOS
? linkWithParams(APP_STORE_LINK, options?.appStoreParams)
: linkWithParams(MICROSITE_LINK, options?.microSiteParams)