Skip to content

Commit

Permalink
Fix ens destructuring (#887)
Browse files Browse the repository at this point in the history
## What has been done

Fixes error with `ens` destructuring 

## Screenshots / images / videos


![image](https://github.com/tahowallet/dapp/assets/73061939/52178c41-afa2-4ee8-82be-02d1738e6091)
  • Loading branch information
jagodarybacka authored Dec 14, 2023
2 parents 80e931b + b60b45e commit ae479e9
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/shared/hooks/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,26 @@ export function useCachedWalletName() {

useEffect(() => {
const handleCachedNamesUpdate = () => {
if (!address) return

const cachedNames = localStorage.getItem(LOCAL_STORAGE_CACHED_NAMES)
if (!cachedNames) return

const parsedCachedNames: CachedNames = JSON.parse(cachedNames)
const { ens, uns } = parsedCachedNames[address]

if (ens || uns) {
// If cached name and redux wallet name are the same do not dispatch wallet update action
if (walletName === ens?.name || walletName === uns?.name) return

dispatch(
updateConnectedWallet({ address, name: ens?.name ?? uns?.name })
)
try {
if (!address) return

const cachedNames = localStorage.getItem(LOCAL_STORAGE_CACHED_NAMES)
if (!cachedNames) return

const parsedCachedNames: CachedNames = JSON.parse(cachedNames)
const { ens, uns } = parsedCachedNames[address] ?? {}

if (ens || uns) {
// If cached name and redux wallet name are the same do not dispatch wallet update action
if (walletName === ens?.name || walletName === uns?.name) return

dispatch(
updateConnectedWallet({ address, name: ens?.name ?? uns?.name })
)
}
} catch (err) {
// eslint-disable-next-line no-console
console.error(err)
}
}

Expand Down

0 comments on commit ae479e9

Please sign in to comment.