From 70026a7694052ea4578ae7f4124d5062b0eb6c04 Mon Sep 17 00:00:00 2001 From: Adrian Tiberius Date: Tue, 5 Jul 2016 19:14:41 +0300 Subject: [PATCH] renamed users to accounts and fixed current account setting Former-commit-id: 6841e8e430ace8b939fa6eaea5e5c364142d5e18 --- src/status_im/accounts/handlers.cljs | 11 +++++++---- src/status_im/{users => accounts}/screen.cljs | 14 +++++++------- src/status_im/{users => accounts}/styles.cljs | 12 ++++++------ src/status_im/{users => accounts}/views/user.cljs | 10 +++++----- src/status_im/android/core.cljs | 4 ++-- src/status_im/users/handlers.cljs | 1 - src/status_im/users/subs.cljs | 1 - 7 files changed, 27 insertions(+), 26 deletions(-) rename src/status_im/{users => accounts}/screen.cljs (89%) rename src/status_im/{users => accounts}/styles.cljs (90%) rename src/status_im/{users => accounts}/views/user.cljs (86%) delete mode 100644 src/status_im/users/handlers.cljs delete mode 100644 src/status_im/users/subs.cljs diff --git a/src/status_im/accounts/handlers.cljs b/src/status_im/accounts/handlers.cljs index a3d6550853..7525fe61be 100644 --- a/src/status_im/accounts/handlers.cljs +++ b/src/status_im/accounts/handlers.cljs @@ -33,9 +33,9 @@ (when (not (str/blank? public-key)) (do (save-password password) + (dispatch [:add-account account]) (dispatch [:login-account address password]) - (dispatch [:initialize-protocol account]) - (dispatch [:add-account account]))))) + (dispatch [:initialize-protocol account]))))) (register-handler :create-account (-> (fn [db [_ password]] @@ -44,5 +44,8 @@ (register-handler :login-account (-> (fn [db [_ address password]] - (.login geth address password (fn [result] (log/debug "Logged in account: " address result))) - db))) \ No newline at end of file + (.login geth address password (fn [result] + (log/debug "Logged in account: " address result) + (dispatch [:set :current-account (get-in db [:accounts address])]))) + db))) + diff --git a/src/status_im/users/screen.cljs b/src/status_im/accounts/screen.cljs similarity index 89% rename from src/status_im/users/screen.cljs rename to src/status_im/accounts/screen.cljs index 09de1948e6..34cc1d1982 100644 --- a/src/status_im/users/screen.cljs +++ b/src/status_im/accounts/screen.cljs @@ -1,4 +1,4 @@ -(ns status-im.users.screen +(ns status-im.accounts.screen (:require-macros [status-im.utils.views :refer [defview]]) (:require [re-frame.core :refer [subscribe dispatch dispatch-sync]] [status-im.components.react :refer [view @@ -21,9 +21,9 @@ button-input white-form-text-input]] [status-im.utils.listview :as lw] - [status-im.users.views.user :refer [user-view]] + [status-im.accounts.views.account :refer [account-view]] [status-im.i18n :refer [label]] - [status-im.users.styles :as st])) + [status-im.accounts.styles :as st])) (def toolbar-title [view toolbar-title-container @@ -31,13 +31,13 @@ (label :t/switch-users)]]) (defn render-row [row _ _] - (list-item [user-view row])) + (list-item [account-view row])) (defn render-separator [_ row-id _] (list-item [view {:style st/row-separator :key row-id}])) -(defview users [] +(defview accounts [] [accounts [:get :accounts]] (let [accounts (conj (vals accounts) {:name (label :t/add-account) :address "0x0" @@ -57,12 +57,12 @@ :action {:image {:style icon-search} :handler #()}}] - [view st/user-list-container + [view st/account-list-container [list-view {:dataSource (lw/to-datasource accounts) :enableEmptySections true :renderRow render-row :renderSeparator render-separator - :style st/user-list}]]])) + :style st/account-list}]]])) ;(re-frame.core/dispatch [:set :view-id :users]) \ No newline at end of file diff --git a/src/status_im/users/styles.cljs b/src/status_im/accounts/styles.cljs similarity index 90% rename from src/status_im/users/styles.cljs rename to src/status_im/accounts/styles.cljs index 1c580d8f73..ac899e71bb 100644 --- a/src/status_im/users/styles.cljs +++ b/src/status_im/accounts/styles.cljs @@ -1,4 +1,4 @@ -(ns status-im.users.styles +(ns status-im.accounts.styles (:require [status-im.components.styles :refer [font title-font text1-color @@ -18,7 +18,7 @@ :bottom 0 :left 0}) -(def user-list-container1 +(def account-list-container1 {:position :absolute :top 56 :right 0 @@ -26,19 +26,19 @@ :left 0 :justifyContent :center}) -(def user-list-container +(def account-list-container {:flex 1 :flexDirection :column :justifyContent :center}) -(def user-list +(def account-list {}) (def row-separator {:borderBottomWidth 1 :borderBottomColor "#bababa"}) -(def user-container +(def account-container {:flex 1 :flexDirection :row :height 69 @@ -52,7 +52,7 @@ :alignItems :center :justifyContent :center}) -(def user-photo-container +(def account-photo-container {:flex 1 :backgroundColor "rgba(255, 255, 255, 0.2)" :borderRadius 50 diff --git a/src/status_im/users/views/user.cljs b/src/status_im/accounts/views/user.cljs similarity index 86% rename from src/status_im/users/views/user.cljs rename to src/status_im/accounts/views/user.cljs index daf1a41387..af714d566e 100644 --- a/src/status_im/users/views/user.cljs +++ b/src/status_im/accounts/views/user.cljs @@ -1,4 +1,4 @@ -(ns status-im.users.views.user +(ns status-im.accounts.views.account (:require-macros [status-im.utils.views :refer [defview]]) (:require [clojure.string :as s] [status-im.resources :as res] @@ -9,19 +9,19 @@ [re-frame.core :refer [dispatch subscribe]] [status-im.components.styles :refer [icon-ok icon-plus]] - [status-im.users.styles :as st])) + [status-im.accounts.styles :as st])) (defn on-press [address] (dispatch [:navigate-to :login address]) (dispatch [:set-in [:login :address] address])) -(defview user-view [{:keys [address photo-path name] :as account}] +(defview account-view [{:keys [address photo-path name] :as account}] [current-account [:get :current-account]] [touchable-highlight {:onPress #(on-press address)} - [view st/user-container + [view st/account-container [view st/photo-container - [view st/user-photo-container + [view st/account-photo-container (if (not= address "0x0") [image {:source {:uri (if (s/blank? photo-path) :avatar photo-path)} :style st/photo-image}] diff --git a/src/status_im/android/core.cljs b/src/status_im/android/core.cljs index f71789f8ab..bc6406e039 100644 --- a/src/status_im/android/core.cljs +++ b/src/status_im/android/core.cljs @@ -15,7 +15,7 @@ [status-im.discovery.tag :refer [discovery-tag]] [status-im.chat.screen :refer [chat]] [status-im.login.screen :refer [login]] - [status-im.users.screen :refer [users]] + [status-im.accounts.screen :refer [accounts]] [status-im.chats-list.screen :refer [chats-list]] [status-im.new-group.screen :refer [new-group]] [status-im.participants.views.add :refer [new-participants]] @@ -78,7 +78,7 @@ :qr-scanner [qr-scanner] :chat [chat] :profile [profile] - :users [users] + :users [accounts] :login [login] :my-profile [my-profile]))}))) diff --git a/src/status_im/users/handlers.cljs b/src/status_im/users/handlers.cljs deleted file mode 100644 index 7aa5f85efa..0000000000 --- a/src/status_im/users/handlers.cljs +++ /dev/null @@ -1 +0,0 @@ -(ns status-im.users.handlers) \ No newline at end of file diff --git a/src/status_im/users/subs.cljs b/src/status_im/users/subs.cljs deleted file mode 100644 index 805245ffd2..0000000000 --- a/src/status_im/users/subs.cljs +++ /dev/null @@ -1 +0,0 @@ -(ns status-im.users.subs) \ No newline at end of file