From 202db63f61846cb3ef3e6e9a13cb7443ead60090 Mon Sep 17 00:00:00 2001 From: Nikos Kontakis Date: Fri, 20 Sep 2024 16:38:01 +0300 Subject: [PATCH] Add easter egg (#156) --- src/components/RedirectByName.tsx | 38 +++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/components/RedirectByName.tsx b/src/components/RedirectByName.tsx index 5e48fa5..a935f81 100644 --- a/src/components/RedirectByName.tsx +++ b/src/components/RedirectByName.tsx @@ -11,15 +11,27 @@ export const RedirectByName = () => { const [address, setAddress] = useState('') const { selectNetwork } = useNetwork() + const [redirectionNetwork, setRedirectionNetwork] = useState('') + + useEffect(() => { + const netw = + network === 'porkydot' + ? 'polkadot' + : network === 'kus000mba' + ? 'kusama' + : network || '' + setRedirectionNetwork(netw) + }, [network]) + useEffect(() => { - if (!network || !isSupportedNetwork(network)) { + if (!redirectionNetwork || !isSupportedNetwork(redirectionNetwork)) { setIsDelegateMissing(true) return } - selectNetwork(network) - }, [network, selectNetwork]) + selectNetwork(redirectionNetwork) + }, [redirectionNetwork, selectNetwork]) useEffect(() => { if (!name) { @@ -36,10 +48,22 @@ export const RedirectByName = () => { } else { setAddress(delegate.address) } - }, [getDelegateByName, isDelegateLoading, name, network, selectNetwork]) + }, [ + getDelegateByName, + isDelegateLoading, + name, + redirectionNetwork, + selectNetwork, + ]) - if (address && !!network && isSupportedNetwork(network)) { - return + if ( + address && + !!redirectionNetwork && + isSupportedNetwork(redirectionNetwork) + ) { + return ( + + ) } if (!isDelegateMissing) { @@ -50,7 +74,7 @@ export const RedirectByName = () => {
Delegate not found for name:{' '} {name} and network:{' '} - {network} + {redirectionNetwork}
) }