From 8285ab304bdce841f7a91ed71d74053e85f7dfe3 Mon Sep 17 00:00:00 2001 From: Vasyl Ivanchuk Date: Tue, 21 Nov 2023 14:27:06 +0200 Subject: [PATCH] fix: token icon label (#94) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # What ❔ Refactor TokenIconLabel component and its usage. ## Why ❔ The problem came from the local environment where we don't have ETH in DB and it's not returned by the tokens endpoint so the custom token icon is shown: image since we already have a token icon url in upsteam components - we can just pass it to TokenIconLabel component and simplify the component itself. image ## Checklist - [X] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [X] Tests for the changes have been added / updated. --- .../app/src/components/TokenAmountPrice.vue | 8 +- .../app/src/components/TokenIconLabel.vue | 24 +----- .../app/src/components/balances/Table.vue | 1 + .../TokenAmountPriceTableCell.vue | 8 +- .../infoTable/TransferTableCell.vue | 1 + .../tests/components/TokenIconLabel.spec.ts | 79 ++----------------- 6 files changed, 24 insertions(+), 97 deletions(-) diff --git a/packages/app/src/components/TokenAmountPrice.vue b/packages/app/src/components/TokenAmountPrice.vue index c5364906c7..e56dd2a591 100644 --- a/packages/app/src/components/TokenAmountPrice.vue +++ b/packages/app/src/components/TokenAmountPrice.vue @@ -3,7 +3,13 @@
diff --git a/packages/app/src/components/TokenIconLabel.vue b/packages/app/src/components/TokenIconLabel.vue index 56dc4adae5..39675f1fd0 100644 --- a/packages/app/src/components/TokenIconLabel.vue +++ b/packages/app/src/components/TokenIconLabel.vue @@ -11,7 +11,7 @@
@@ -35,8 +35,6 @@ import { useImage } from "@vueuse/core"; import AddressLink from "@/components/AddressLink.vue"; -import useTokenLibrary from "@/composables/useTokenLibrary"; - import type { Hash } from "@/types"; export type IconSize = "sm" | "md" | "lg" | "xl"; @@ -57,7 +55,7 @@ const props = defineProps({ default: "sm", }, iconUrl: { - type: String, + type: [String, null] as PropType, default: "", }, showLinkSymbol: { @@ -70,26 +68,10 @@ const props = defineProps({ }, }); -const { - isRequestPending: isTokensRequestPending, - isRequestFailed: isTokensRequestFailed, - getToken, - getTokens, -} = useTokenLibrary(); - -getTokens(); - const imgSource = computed(() => { - if (props.iconUrl) { - return props.iconUrl; - } - const tokenFromLibrary = getToken(props.address); - return tokenFromLibrary?.iconURL ? tokenFromLibrary.iconURL : "/images/currencies/customToken.svg"; + return props.iconUrl || "/images/currencies/customToken.svg"; }); const { isReady: isImageLoaded } = useImage({ src: imgSource.value }); -const isImageReady = computed( - () => (!isTokensRequestPending.value && !isTokensRequestFailed.value && isImageLoaded.value) || props.iconUrl -);