From b18d6b06c7c677b2291b71b6c98d884e6ce43549 Mon Sep 17 00:00:00 2001 From: psdp <4315882+psdp@users.noreply.github.com> Date: Thu, 26 Apr 2018 14:39:05 +0000 Subject: [PATCH] Sort Assets in alphabetical order on Wallet -> Manage Assets screen #3926 --- src/status_im/ui/screens/wallet/settings/views.cljs | 2 +- src/status_im/utils/ethereum/tokens.cljs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/status_im/ui/screens/wallet/settings/views.cljs b/src/status_im/ui/screens/wallet/settings/views.cljs index 30db1b9d42..11b206e11d 100644 --- a/src/status_im/ui/screens/wallet/settings/views.cljs +++ b/src/status_im/ui/screens/wallet/settings/views.cljs @@ -33,6 +33,6 @@ [toolbar/content-title {:color :white} (i18n/label :t/wallet-assets)]] [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) :render-fn #(render-token % visible-tokens)}]]])) diff --git a/src/status_im/utils/ethereum/tokens.cljs b/src/status_im/utils/ethereum/tokens.cljs index 6d8a20474b..0dcd394b60 100644 --- a/src/status_im/utils/ethereum/tokens.cljs +++ b/src/status_im/utils/ethereum/tokens.cljs @@ -1,5 +1,6 @@ (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] {:border-color color :border-width 1 :border-radius 32}) @@ -407,6 +408,11 @@ (defn tokens-for [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] (some #(when (= symbol (:symbol %)) %) (tokens-for chain)))