Skip to content

Commit

Permalink
Use safeAddress + chainId instead of raw query
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Oct 26, 2023
1 parent 1024bb7 commit 2a67f33
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/components/tx-flow/index.tsx
Original file line number Diff line number Diff line change
@@ -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 = () => {}

Expand All @@ -26,9 +27,8 @@ export const TxModalProvider = ({ children }: { children: ReactNode }): ReactEle
const [fullWidth, setFullWidth] = useState<boolean>(false)
const shouldWarn = useRef<boolean>(true)
const onClose = useRef<() => void>(noop)
const searchParams = useSearchParams()
const safeQuery = searchParams.get('safe')
const prevQuery = useRef<string>(safeQuery ?? '')
const safeId = useChainId() + useSafeAddress()
const prevSafeId = useRef<string>(safeId ?? '')

const handleModalClose = useCallback(() => {
onClose.current()
Expand Down Expand Up @@ -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 (
<TxModalContext.Provider value={{ txFlow, setTxFlow, setFullWidth }}>
Expand Down

0 comments on commit 2a67f33

Please sign in to comment.