From 8a75d5d68c6bf778a10702af60e7badc28eca4f5 Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Thu, 1 Feb 2018 16:32:10 +0200 Subject: [PATCH] Address dropdown: Apply case-insensitive comparison only during component setup --- src/cljs/commiteth/update_address.cljs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cljs/commiteth/update_address.cljs b/src/cljs/commiteth/update_address.cljs index 60e298f..14ceaa1 100644 --- a/src/cljs/commiteth/update_address.cljs +++ b/src/cljs/commiteth/update_address.cljs @@ -11,8 +11,7 @@ (let [db (rf/subscribe [:db]) user (rf/subscribe [:user]) updating-address (rf/subscribe [:get-in [:updating-address]]) - address (r/atom (some-> @(rf/subscribe [:get-in [:user :address]]) - str/lower-case))] + address (r/atom @(rf/subscribe [:get-in [:user :address]]))] (fn [] (let [web3 (:web3 @db) web3-accounts (when web3 @@ -29,12 +28,14 @@ (let [accounts (map str/lower-case web3-accounts) addr @address title "Select address" - items (cond->> accounts - (and addr - (not (contains? (set accounts) addr))) - (into [addr]) - (not addr) - (into [title]))] + addr-not-in-web3? (and addr (as-> web3-accounts acc + (map str/lower-case acc) + (set acc) + (contains? acc addr) + (not acc))) + items (cond->> web3-accounts + addr-not-in-web3? (into [addr]) + (not addr) (into [title]))] [dropdown {:class "address-input"} title address