Sort Assets in alphabetical order on Wallet -> Manage Assets screen #3926

This commit is contained in:
psdp 2018-04-26 14:39:05 +00:00 committed by Roman Volosovskyi
parent 0d0be37904
commit b18d6b06c7
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 8 additions and 2 deletions

View File

@ -33,6 +33,6 @@
[toolbar/content-title {:color :white} [toolbar/content-title {:color :white}
(i18n/label :t/wallet-assets)]] (i18n/label :t/wallet-assets)]]
[react/view {:style components.styles/flex} [react/view {:style components.styles/flex}
[list/flat-list {:data (tokens/tokens-for (ethereum/network->chain-keyword network)) [list/flat-list {:data (tokens/sorted-tokens-for (ethereum/network->chain-keyword network))
:key-fn (comp str :symbol) :key-fn (comp str :symbol)
:render-fn #(render-token % visible-tokens)}]]])) :render-fn #(render-token % visible-tokens)}]]]))

View File

@ -1,5 +1,6 @@
(ns status-im.utils.ethereum.tokens (ns status-im.utils.ethereum.tokens
(:require-macros [status-im.utils.ethereum.macros :refer [resolve-icons]])) (:require-macros [status-im.utils.ethereum.macros :refer [resolve-icons]])
(:require [clojure.string :as string]))
(defn- asset-border [color] (defn- asset-border [color]
{:border-color color :border-width 1 :border-radius 32}) {:border-color color :border-width 1 :border-radius 32})
@ -407,6 +408,11 @@
(defn tokens-for [chain] (defn tokens-for [chain]
(get all chain)) (get all chain))
(defn sorted-tokens-for [chain]
(->> (tokens-for chain)
(sort #(compare (string/lower-case (:name %1))
(string/lower-case (:name %2))))))
(defn symbol->token [chain symbol] (defn symbol->token [chain symbol]
(some #(when (= symbol (:symbol %)) %) (tokens-for chain))) (some #(when (= symbol (:symbol %)) %) (tokens-for chain)))