Skip to content

Commit

Permalink
better comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
KorbinianK committed May 7, 2024
1 parent a140beb commit 477553d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { deepEqual } from '@wagmi/core';
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
import { t } from 'svelte-i18n';
import type { Address } from 'viem';
Expand Down Expand Up @@ -115,7 +116,7 @@
<ul role="listbox" class="menu p-0">
{#if activeTab === TabTypes.TOKEN}
{#each filteredTokens as token (token.symbol)}
{@const selected = token === value}
{@const selected = deepEqual(token, value)}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<li
role="option"
Expand All @@ -141,7 +142,7 @@
{:else if activeTab === TabTypes.CUSTOM}
{#if !onlyMintable}
{#each filteredCustomTokens as ct, index (index)}
{@const selected = ct.name === value?.name && ct.symbol === value?.symbol}
{@const selected = deepEqual(ct, value)}
<li
role="option"
tabindex="0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { deepEqual } from '@wagmi/core';
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
import { t } from 'svelte-i18n';
import type { Address } from 'viem';
Expand Down Expand Up @@ -121,7 +122,7 @@
<ul role="listbox" {id} class="gap-2">
{#if activeTab === TabTypes.TOKEN}
{#each filteredTokens as t (t.symbol)}
{@const selected = t === value}
{@const selected = deepEqual(t, value)}
<li
role="option"
tabindex="0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { deepEqual } from '@wagmi/core';
import { onDestroy, onMount, tick } from 'svelte';
import { t } from 'svelte-i18n';
import type { Address } from 'viem';
Expand Down Expand Up @@ -130,11 +131,11 @@
const handleTokenRemoved = (event: { detail: { token: Token } }) => {
const token = event.detail.token;
value = ETHToken;
// if the selected token is the one that was removed by the user, remove it
// if (token === value || $selectedToken === token) {
// value = ETHToken;
// }
if (deepEqual(token, value)) {
value = ETHToken;
}
const address = $account.address;
tokenService.removeToken(token, address as Address);
customTokens = tokenService.getTokens(address as Address);
Expand Down

0 comments on commit 477553d

Please sign in to comment.