Skip to content

Commit

Permalink
remove timeout; use WalletClient to determine client connection state
Browse files Browse the repository at this point in the history
  • Loading branch information
Da-Colon committed Mar 4, 2024
1 parent e5ae638 commit 9886b81
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/components/ui/menus/AccountDisplay/MenuItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -33,25 +30,22 @@ export function MenuItems() {
},
}}
>
{user.address && <MenuItemWallet />}
{isConnected && <MenuItemWallet />}
<MenuItemNetwork />
{!user.address && (
{!isConnected && (
<MenuItemButton
testId="accountMenu-connect"
label={t('connect')}
Icon={Connect}
onClick={openConnectModal}
/>
)}
{user.address && (
{isConnected && (
<MenuItemButton
testId="accountMenu-disconnect"
label={t('disconnect')}
Icon={Disconnect}
onClick={() => {
disconnect();
setTimeout(() => {}, 500);
}}
onClick={disconnect}
/>
)}
</MenuList>
Expand Down

0 comments on commit 9886b81

Please sign in to comment.