Skip to content

Commit a76fb1f

Browse files
fix: disconnect the modal and open the modal when there is an arleady connection
1 parent 5e61c4c commit a76fb1f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/components/sections/profile/modals/EditAddress/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default function EditProfile({ show, wallet, onClose }: EditProfileProps)
9595

9696
const connect = async () => {
9797
try {
98-
openWeb3Modal();
98+
isConnected ? disconnect() : openWeb3Modal();
9999
setShowEditAddress(true);
100100
} catch (e) {
101101
console.log(e);
@@ -137,8 +137,8 @@ export default function EditProfile({ show, wallet, onClose }: EditProfileProps)
137137
}, [wallets?.require_wallet_connection]);
138138

139139
const isWalletConnected = useMemo(() => {
140-
return isConnected || (requireWalletConnection && !!wallet?.address);
141-
}, [requireWalletConnection, wallet?.address, isConnected]);
140+
return requireWalletConnection && !!wallet?.address;
141+
}, [requireWalletConnection, wallet?.address]);
142142

143143
const showForm = useMemo(() => {
144144
return Boolean(showEditAddress && !showWalletConnectionMethod && connectionMethod);

src/hooks/useWalletConnect.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ import { useWeb3Modal } from "@web3modal/wagmi/react";
22
import { useAccount, useDisconnect, useSignMessage } from "wagmi";
33

44
export default function useWalletConnect() {
5-
const { isConnected, address } = useAccount();
65
const { open } = useWeb3Modal();
6+
const { isConnected, address } = useAccount({
7+
onDisconnect: () => {
8+
open(); //open the modal again
9+
},
10+
});
711
const { data, isLoading, signMessage, error } = useSignMessage();
812
const { disconnect } = useDisconnect();
913

0 commit comments

Comments
 (0)