Commit b12e5270 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

fix: sync network connector to wallet (#4985)

* fix: sync network connector to wallet

* fix: clean todos
parent a7178189
...@@ -6,6 +6,7 @@ import { CUSTOM_USER_PROPERTIES, EventName, WALLET_CONNECTION_RESULT } from 'ana ...@@ -6,6 +6,7 @@ import { CUSTOM_USER_PROPERTIES, EventName, WALLET_CONNECTION_RESULT } from 'ana
import { sendEvent } from 'components/analytics' import { sendEvent } from 'components/analytics'
import { AutoColumn } from 'components/Column' import { AutoColumn } from 'components/Column'
import { AutoRow } from 'components/Row' import { AutoRow } from 'components/Row'
import { networkConnection } from 'connection'
import { getConnection, getConnectionName, getIsCoinbaseWallet, getIsInjected, getIsMetaMask } from 'connection/utils' import { getConnection, getConnectionName, getIsCoinbaseWallet, getIsInjected, getIsMetaMask } from 'connection/utils'
import { NftVariant, useNftFlag } from 'featureFlags/flags/nft' import { NftVariant, useNftFlag } from 'featureFlags/flags/nft'
import usePrevious from 'hooks/usePrevious' import usePrevious from 'hooks/usePrevious'
...@@ -189,6 +190,13 @@ export default function WalletModal({ ...@@ -189,6 +190,13 @@ export default function WalletModal({
} }
}, [pendingConnector, walletView]) }, [pendingConnector, walletView])
// Keep the network connector in sync with any active user connector to prevent chain-switching on wallet disconnection.
useEffect(() => {
if (chainId && connector !== networkConnection.connector) {
networkConnection.connector.activate(chainId)
}
}, [chainId, connector])
// When new wallet is successfully set by the user, trigger logging of Amplitude analytics event. // When new wallet is successfully set by the user, trigger logging of Amplitude analytics event.
useEffect(() => { useEffect(() => {
if (account && account !== lastActiveWalletAddress) { if (account && account !== lastActiveWalletAddress) {
......
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