From 43f2aeb85165e79e58673e8457aca4bbb4feca85 Mon Sep 17 00:00:00 2001 From: saml33 Date: Sun, 3 Mar 2024 13:46:35 +1100 Subject: [PATCH] fix secondary connect button on mobile adapter --- components/shared/SecondaryConnectButton.tsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/components/shared/SecondaryConnectButton.tsx b/components/shared/SecondaryConnectButton.tsx index c0c65c6..38822c4 100644 --- a/components/shared/SecondaryConnectButton.tsx +++ b/components/shared/SecondaryConnectButton.tsx @@ -3,14 +3,11 @@ import Button from './Button' import { useWallet } from '@solana/wallet-adapter-react' import useLocalStorageState from 'hooks/useLocalStorageState' import { WalletName, WalletReadyState } from '@solana/wallet-adapter-base' -import { AUTO_CONNECT_WALLET, LAST_WALLET_NAME } from 'utils/constants' +import { LAST_WALLET_NAME } from 'utils/constants' import { notify } from 'utils/notifications' -import mangoStore from '@store/mangoStore' import { useCallback } from 'react' import WalletIcon from '@components/icons/WalletIcon' -const set = mangoStore.getState().set - const SecondaryConnectButton = ({ className, isLarge, @@ -19,18 +16,15 @@ const SecondaryConnectButton = ({ isLarge?: boolean }) => { const { t } = useTranslation('common') - const { wallets, select } = useWallet() + const { connect, wallet, wallets, select } = useWallet() const [lastWalletName] = useLocalStorageState( LAST_WALLET_NAME, '', ) - const [autoConnect] = useLocalStorageState(AUTO_CONNECT_WALLET, true) const handleConnect = useCallback(() => { - if (!autoConnect) { - set((s) => { - s.showUserSetup = true - }) + if (wallet) { + connect() } else if (lastWalletName) { select(lastWalletName) } else { @@ -48,7 +42,7 @@ const SecondaryConnectButton = ({ }) } } - }, [autoConnect, lastWalletName, select, wallets]) + }, [connect, lastWalletName, select, wallet, wallets]) return (