From 9886b8144c631e7022912f4603040e83dcad3988 Mon Sep 17 00:00:00 2001 From: David Colon <38386583+Da-Colon@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:02:46 -0500 Subject: [PATCH] remove timeout; use WalletClient to determine client connection state --- .../ui/menus/AccountDisplay/MenuItems.tsx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/components/ui/menus/AccountDisplay/MenuItems.tsx b/src/components/ui/menus/AccountDisplay/MenuItems.tsx index 8aedd357a6..a34558f92c 100644 --- a/src/components/ui/menus/AccountDisplay/MenuItems.tsx +++ b/src/components/ui/menus/AccountDisplay/MenuItems.tsx @@ -2,17 +2,14 @@ import { MenuList } from '@chakra-ui/react'; import { Connect, Disconnect } from '@decent-org/fractal-ui'; import { useConnectModal } from '@rainbow-me/rainbowkit'; import { useTranslation } from 'react-i18next'; -import { useDisconnect } from 'wagmi'; -import { useFractal } from '../../../../providers/App/AppProvider'; +import { useDisconnect, useWalletClient } from 'wagmi'; import { MenuItemButton } from './MenuItemButton'; import { MenuItemNetwork } from './MenuItemNetwork'; import { MenuItemWallet } from './MenuItemWallet'; export function MenuItems() { - const { - readOnly: { user }, - } = useFractal(); const { disconnect } = useDisconnect(); + const { data: isConnected } = useWalletClient(); const { openConnectModal } = useConnectModal(); const { t } = useTranslation('menu'); return ( @@ -33,9 +30,9 @@ export function MenuItems() { }, }} > - {user.address && } + {isConnected && } - {!user.address && ( + {!isConnected && ( )} - {user.address && ( + {isConnected && ( { - disconnect(); - setTimeout(() => {}, 500); - }} + onClick={disconnect} /> )}