Skip to content

Commit

Permalink
close wallet dialog upon selection (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
wirednkod authored Sep 19, 2024
1 parent 228fc48 commit dc08011
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ export const Header = () => {
const { network, selectNetwork, lightClientLoaded, isLight } = useNetwork()
const { accounts, selectAccount, selectedAccount } = useAccounts()
const [, disconnectAll] = useWalletDisconnector()
const [isConnectionDialiogOpen, setIsConnectionDialiogOpen] = useState(false)
const [isConnectionDialogOpen, setIsConnectionDialogOpen] = useState(false)
// eslint-disable-next-line
const { theme, setTheme } = useTheme()
const { search } = useLocation()

useEffect(() => {
if (!selectedAccount?.address && accounts.length > 0) {
selectAccount(accounts[0])
setIsConnectionDialogOpen(false)
}
}, [accounts, selectAccount, selectedAccount?.address])

Expand Down Expand Up @@ -164,7 +165,7 @@ export const Header = () => {
</DropdownMenuContent>
</DropdownMenu>
{!accounts.length && (
<Button onClick={() => setIsConnectionDialiogOpen(true)}>
<Button onClick={() => setIsConnectionDialogOpen(true)}>
Connect
</Button>
)}
Expand Down Expand Up @@ -207,6 +208,15 @@ export const Header = () => {
)}
</>
))}
<DropdownMenuItem
className="cursor-pointer"
key={'show'}
onClick={() => {
setIsConnectionDialogOpen(true)
}}
>
Show wallets
</DropdownMenuItem>
<DropdownMenuItem
className="cursor-pointer"
key={'logout'}
Expand All @@ -224,8 +234,8 @@ export const Header = () => {
</div>
</header>
<ConnectionDialog
open={isConnectionDialiogOpen}
onClose={() => setIsConnectionDialiogOpen(false)}
open={isConnectionDialogOpen}
onClose={() => setIsConnectionDialogOpen(false)}
/>
</>
)
Expand Down

0 comments on commit dc08011

Please sign in to comment.