Skip to content

Commit

Permalink
reset external account param only when its present in url
Browse files Browse the repository at this point in the history
  • Loading branch information
jvonasek committed Jun 28, 2024
1 parent d5addd7 commit d5f762a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/sections/web3-connect/accounts/Web3ConnectEvmAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useNavigate } from "@tanstack/react-location"
import { useNavigate, useSearch } from "@tanstack/react-location"
import { Button } from "components/Button/Button"
import { DisplayValue } from "components/DisplayValue/DisplayValue"
import { Text } from "components/Typography/Text/Text"
Expand All @@ -18,6 +18,7 @@ export const Web3ConnectEvmAccount: FC<
const { account: currentAccount, setAccount, toggle } = useWeb3ConnectStore()
const { wallet } = useWallet()
const navigate = useNavigate()
const search = useSearch()

const isActive = currentAccount?.address === account.address

Expand All @@ -33,7 +34,7 @@ export const Web3ConnectEvmAccount: FC<
onClick={() => {
setAccount(account)
toggle()
navigate({ search: { account: undefined } })
if (search.account) navigate({ search: { account: undefined } })
}}
>
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ComponentPropsWithoutRef } from "react"
import { useWeb3ConnectStore } from "sections/web3-connect/store/useWeb3ConnectStore"
import { useNavigate } from "@tanstack/react-location"
import { useNavigate, useSearch } from "@tanstack/react-location"
import { Web3ConnectAccount } from "./Web3ConnectAccount"

export const Web3ConnectSubstrateAccount: React.FC<
ComponentPropsWithoutRef<typeof Web3ConnectAccount>
> = ({ balance, ...account }) => {
const { account: currentAccount, setAccount, toggle } = useWeb3ConnectStore()
const navigate = useNavigate()
const search = useSearch()
const isActive = currentAccount?.address === account.address

return (
Expand All @@ -18,7 +19,7 @@ export const Web3ConnectSubstrateAccount: React.FC<
onClick={(account) => {
setAccount(account)
toggle()
navigate({ search: { account: undefined } })
if (search.account) navigate({ search: { account: undefined } })
}}
/>
)
Expand Down

0 comments on commit d5f762a

Please sign in to comment.