diff --git a/src/components/PsaBanner/index.tsx b/src/components/PsaBanner/index.tsx index 2b0eb89a9f..025ab45c53 100644 --- a/src/components/PsaBanner/index.tsx +++ b/src/components/PsaBanner/index.tsx @@ -7,6 +7,7 @@ import { hasFeature } from 'src/logic/safe/utils/safeVersion' import useCachedState from 'src/utils/storage/useCachedState' import styles from './index.module.scss' import Countdown from './Countdown' +import { useLocation } from 'react-router-dom' const NEW_URL = 'https://app.safe.global' @@ -15,25 +16,47 @@ const redirectToNewApp = (): void => { window.location.replace(NEW_URL + path) } -const BANNERS: Record = { - '*': ( +const WARNING_BANNER = 'WARNING_BANNER' +const NO_REDIRECT_PARAM = 'no-redirect' + +const WebCoreBanner = (): ReactElement | null => { + const { search } = useLocation() + const [shouldRedirect = true, setShouldRedirect] = useCachedState(`${WARNING_BANNER}_shouldRedirect`, true) + + useEffect(() => { + // Prevent refresh from overwriting the cached value + const noRedirect = new URLSearchParams(search).get(NO_REDIRECT_PARAM) + if (noRedirect) { + setShouldRedirect(false) + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []) + + return ( <> ⚠️ Safe's new official URL is app.safe.global.
Please update your bookmarks.{' '} - - {(count) => <>Redirecting in {count} seconds...} - + {shouldRedirect && ( + + {(count) => <>Redirecting in {count} seconds...} + + )} - ), + ) } -const WARNING_BANNER = 'WARNING_BANNER' +const BANNERS: Record = { + '*': , +} const PsaBanner = (): ReactElement | null => { const chainId = useSelector(currentChainId) const banner = BANNERS[chainId] || BANNERS['*'] const isEnabled = hasFeature(WARNING_BANNER as FEATURES) - const [closed = false, setClosed] = useCachedState(`${WARNING_BANNER}_${chainId}_closed`, true) + const [closed = false, setClosed] = useCachedState( + BANNERS[chainId] ? `${WARNING_BANNER}_${chainId}_closed` : `${WARNING_BANNER}_closed`, + true, + ) const showBanner = Boolean(isEnabled && banner && !closed)