From 2343d9be1edb4d46e468b5b40fc3154884d6228a Mon Sep 17 00:00:00 2001 From: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com> Date: Thu, 5 Dec 2024 20:56:38 +0530 Subject: [PATCH] fix(wallet)_: default token image fallback (#21762) This commit replaces the fallback for an unknown token image (where we display the first letter of the token name) with the default token image Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com> --- src/quo/components/utilities/token/view.cljs | 33 +++++--------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/quo/components/utilities/token/view.cljs b/src/quo/components/utilities/token/view.cljs index 141294a621..d6d44cbc22 100644 --- a/src/quo/components/utilities/token/view.cljs +++ b/src/quo/components/utilities/token/view.cljs @@ -1,7 +1,6 @@ (ns quo.components.utilities.token.view (:require [clojure.string :as string] - [quo.components.markdown.text :as quo] [quo.components.utilities.token.loader :as token-loader] [react-native.core :as rn] [schema.core :as schema] @@ -33,22 +32,7 @@ :height size-number))) (def ^:private b64-png-image-prefix "data:image/png;base64,") - -(defn temp-empty-symbol - [token size style] - [rn/view - {:style (token-style (merge {:justify-content :center - :align-items :center - :border-radius 20 - :border-width 1 - :border-color :grey} - style) - size)} - [quo/text {:style {:color :grey}} - (some-> token - name - first - string/capitalize)]]) +(def ^:const default-token-image (js/require "../resources/images/tokens/default-token.png")) (defn- normalize-b64-string [b64-image] @@ -69,13 +53,12 @@ " [{:keys [token size style image-source] :or {size 32}}] - (let [img-src (if (string? image-source) - (normalize-b64-string image-source) - image-source)] - (if-let [existing-source (or img-src (token-loader/get-token-image token))] - [rn/image - {:style (token-style style size) - :source existing-source}] - [temp-empty-symbol token size style]))) + (let [img-src (if (string? image-source) + (normalize-b64-string image-source) + image-source) + token-image (or img-src (token-loader/get-token-image token) default-token-image)] + [rn/image + {:style (token-style style size) + :source token-image}])) (def view (schema/instrument #'view-internal ?schema))