Commit 6ab6f4da authored by lynn's avatar lynn Committed by GitHub

fix: Revert "fix: use `chain` query param properly when activating" (#6122)

Revert "fix: use `chain` query param properly when activating (#6114)"

This reverts commit ae559d16.
parent ae559d16
...@@ -32,8 +32,6 @@ export default function useSyncChainQuery() { ...@@ -32,8 +32,6 @@ export default function useSyncChainQuery() {
// Can't use `usePrevious` because `chainId` can be undefined while activating. // Can't use `usePrevious` because `chainId` can be undefined while activating.
const [previousChainId, setPreviousChainId] = useState<number | undefined>(undefined) const [previousChainId, setPreviousChainId] = useState<number | undefined>(undefined)
const [nextChainId, setNextChainId] = useState<number | undefined>(undefined)
useEffect(() => { useEffect(() => {
if (chainId && chainId !== previousChainId) { if (chainId && chainId !== previousChainId) {
setPreviousChainId(chainId) setPreviousChainId(chainId)
...@@ -42,21 +40,14 @@ export default function useSyncChainQuery() { ...@@ -42,21 +40,14 @@ export default function useSyncChainQuery() {
const [searchParams, setSearchParams] = useSearchParams() const [searchParams, setSearchParams] = useSearchParams()
useEffect(() => { const chainQueryManuallyUpdated = urlChainId && urlChainId !== previousUrlChainId && isActive
const chainQueryManuallyUpdated = urlChainId && urlChainId !== previousUrlChainId
if (chainQueryManuallyUpdated) {
setNextChainId(urlChainId)
}
}, [previousUrlChainId, urlChainId])
return useEffect(() => { return useEffect(() => {
if (nextChainId && isActive) { if (chainQueryManuallyUpdated) {
// If the query param changed, and the chain didn't change, then activate the new chain // If the query param changed, and the chain didn't change, then activate the new chain
selectChain(nextChainId).then(() => { selectChain(urlChainId)
searchParams.delete('chain') searchParams.delete('chain')
setSearchParams(searchParams) setSearchParams(searchParams)
setNextChainId(undefined)
})
} }
}, [nextChainId, urlChainId, selectChain, searchParams, setSearchParams, isActive]) }, [chainQueryManuallyUpdated, urlChainId, selectChain, searchParams, setSearchParams])
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment