From 2a67f3356a7158f005b40d9fef99f5be9f96c961 Mon Sep 17 00:00:00 2001 From: katspaugh Date: Thu, 26 Oct 2023 17:03:21 +0200 Subject: [PATCH] Use safeAddress + chainId instead of raw query --- src/components/tx-flow/index.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/tx-flow/index.tsx b/src/components/tx-flow/index.tsx index a19d4c6bec..3bce2ffdea 100644 --- a/src/components/tx-flow/index.tsx +++ b/src/components/tx-flow/index.tsx @@ -1,7 +1,8 @@ import { createContext, type ReactElement, type ReactNode, useState, useEffect, useCallback, useRef } from 'react' import TxModalDialog from '@/components/common/TxModalDialog' -import { useSearchParams } from 'next/navigation' import { SuccessScreen } from './flows/SuccessScreen' +import useSafeAddress from '@/hooks/useSafeAddress' +import useChainId from '@/hooks/useChainId' const noop = () => {} @@ -26,9 +27,8 @@ export const TxModalProvider = ({ children }: { children: ReactNode }): ReactEle const [fullWidth, setFullWidth] = useState(false) const shouldWarn = useRef(true) const onClose = useRef<() => void>(noop) - const searchParams = useSearchParams() - const safeQuery = searchParams.get('safe') - const prevQuery = useRef(safeQuery ?? '') + const safeId = useChainId() + useSafeAddress() + const prevSafeId = useRef(safeId ?? '') const handleModalClose = useCallback(() => { onClose.current() @@ -67,14 +67,14 @@ export const TxModalProvider = ({ children }: { children: ReactNode }): ReactEle // // Close the modal when the Safe changes useEffect(() => { - if (safeQuery === prevQuery.current) return - prevQuery.current = safeQuery ?? '' + if (safeId === prevSafeId.current) return + prevSafeId.current = safeId if (txFlow) { handleShowWarning() } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [txFlow, safeQuery]) + }, [txFlow, safeId]) return (