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>
This commit is contained in:
Mohamed Javid 2024-12-05 20:56:38 +05:30 committed by GitHub
parent 7b85bfbd53
commit 2343d9be1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 25 deletions

View File

@ -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]
@ -71,11 +55,10 @@
: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))]
image-source)
token-image (or img-src (token-loader/get-token-image token) default-token-image)]
[rn/image
{:style (token-style style size)
:source existing-source}]
[temp-empty-symbol token size style])))
:source token-image}]))
(def view (schema/instrument #'view-internal ?schema))