@@ -15,7 +15,7 @@ import {
1515import { CustomError } from '@/contexts/ErrorContext' ;
1616import { useWallet } from '@/contexts/WalletContext' ;
1717import { useErrors } from '@/hooks/useErrors' ;
18- import { loginAndUpdateState , clearState } from '@/state' ;
18+ import { clearState , loginAndUpdateState } from '@/state' ;
1919import { t } from '@lingui/core/macro' ;
2020import { Trans } from '@lingui/react/macro' ;
2121import { LogOut , WalletIcon } from 'lucide-react' ;
@@ -29,7 +29,12 @@ interface WalletSwitcherProps {
2929
3030export function WalletSwitcher ( { isCollapsed, logout } : WalletSwitcherProps ) {
3131 const navigate = useNavigate ( ) ;
32- const { wallet : currentWallet , setWallet, setIsSwitching } = useWallet ( ) ;
32+ const {
33+ wallet : currentWallet ,
34+ setWallet,
35+ setIsSwitching,
36+ isSwitching,
37+ } = useWallet ( ) ;
3338 const { addError } = useErrors ( ) ;
3439 const [ wallets , setWallets ] = useState <
3540 { name : string ; fingerprint : number ; emoji : string | null } [ ]
@@ -60,6 +65,10 @@ export function WalletSwitcher({ isCollapsed, logout }: WalletSwitcherProps) {
6065 } , [ addError ] ) ;
6166
6267 const handleSwitchWallet = async ( fingerprint : number ) => {
68+ if ( isSwitching ) {
69+ return ;
70+ }
71+
6372 try {
6473 // Start switching: clear wallet, state, and set switching state
6574 setIsSwitching ( true ) ;
@@ -124,7 +133,9 @@ export function WalletSwitcher({ isCollapsed, logout }: WalletSwitcherProps) {
124133 < DropdownMenuItem
125134 key = { wallet . fingerprint }
126135 onClick = { ( ) => handleSwitchWallet ( wallet . fingerprint ) }
127- disabled = { currentWallet ?. fingerprint === wallet . fingerprint }
136+ disabled = {
137+ isSwitching || currentWallet ?. fingerprint === wallet . fingerprint
138+ }
128139 className = 'grid grid-cols-[auto_1fr_auto] items-center gap-3'
129140 >
130141 < div className = 'w-6 flex items-center justify-center' >
@@ -151,6 +162,7 @@ export function WalletSwitcher({ isCollapsed, logout }: WalletSwitcherProps) {
151162 < DropdownMenuSeparator />
152163 < DropdownMenuItem
153164 onClick = { logout }
165+ disabled = { isSwitching }
154166 className = 'text-destructive focus:text-destructive'
155167 >
156168 < LogOut className = { className } aria-hidden = 'true' />
0 commit comments