From 1464bd97f1cb01fefa0ec373af3b162dddbc7289 Mon Sep 17 00:00:00 2001 From: Adrian Tiberius Date: Wed, 5 Oct 2016 15:19:12 +0300 Subject: [PATCH] fix #280 --- src/status_im/accounts/handlers.cljs | 16 ++++++++------- src/status_im/accounts/login/handlers.cljs | 4 ++-- src/status_im/android/core.cljs | 23 +++++++++++----------- src/status_im/chat/handlers.cljs | 8 ++++---- src/status_im/db.cljs | 2 +- src/status_im/discovery/handlers.cljs | 3 ++- src/status_im/translations/en.cljs | 3 --- 7 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/status_im/accounts/handlers.cljs b/src/status_im/accounts/handlers.cljs index dedc90dfa9..f3ec5c1a97 100644 --- a/src/status_im/accounts/handlers.cljs +++ b/src/status_im/accounts/handlers.cljs @@ -43,9 +43,9 @@ (log/debug "account-created") (when (not (str/blank? public-key)) (do - (dispatch-sync [:add-account account]) - (dispatch-sync [:save-password password mnemonic]) - (dispatch-sync [:login-account address password]))))) + (dispatch [:add-account account]) + (dispatch [:show-mnemonic mnemonic]) + (dispatch [:login-account address password]))))) (register-handler :create-account (u/side-effect! @@ -96,9 +96,8 @@ (defn set-current-account [{:keys [accounts] :as db} [_ address]] (let [key (:public-key (accounts address))] - (-> db - (assoc :current-account-id address) - (assoc :current-public-key key)))) + (assoc db :current-account-id address + :current-public-key key))) (register-handler :set-current-account set-current-account) @@ -107,7 +106,10 @@ (map (fn [{:keys [address] :as account}] [address account])) (into {}))] - (assoc db :accounts accounts))) + (assoc db :accounts accounts + :view-id (if (empty? accounts) + :chat + :accounts)))) (register-handler :load-accounts load-accounts!) diff --git a/src/status_im/accounts/login/handlers.cljs b/src/status_im/accounts/login/handlers.cljs index 5f39b17cfa..6016c64609 100644 --- a/src/status_im/accounts/login/handlers.cljs +++ b/src/status_im/accounts/login/handlers.cljs @@ -26,7 +26,7 @@ (dispatch [:navigate-to :chat console-chat-id])) (do (dispatch [:navigate-to-clean :accounts]) - (dispatch [:navigate-to default-view])))) + (dispatch [:navigate-to :chat-list])))) (register-handler :change-account @@ -45,7 +45,7 @@ [db address] (let [is-login-screen? (= (:view-id db) :login) new-account? (not is-login-screen?)] - (log/debug "Logged in: ") + (log/debug "Logged in: " (:view-id db) is-login-screen? new-account?) (dispatch [:change-account address new-account? on-account-changed]))) (register-handler diff --git a/src/status_im/android/core.cljs b/src/status_im/android/core.cljs index be77a6c3fa..2b15ef8a6d 100644 --- a/src/status_im/android/core.cljs +++ b/src/status_im/android/core.cljs @@ -44,8 +44,15 @@ (defn orientation->keyword [o] (keyword (.toLowerCase o))) +(defn validate-current-view + [current-view signed-up?] + (if (or (contains? #{:login :chat :recover :accounts} current-view) + signed-up?) + current-view + :chat)) + (defn app-root [] - (let [signed-up (subscribe [:signed-up?]) + (let [signed-up? (subscribe [:signed-up?]) view-id (subscribe [:get :view-id]) account-id (subscribe [:get :current-account-id]) keyboard-height (subscribe [:get :keyboard-height])] @@ -71,17 +78,9 @@ (dispatch [:set :keyboard-height 0])))) :render (fn [] - (let [startup-view (if @account-id - (if @signed-up - @view-id - (if (= @view-id :accounts) - :accounts - :chat)) - (if (contains? #{:login :chat :recover} @view-id) - @view-id - :accounts))] - (log/debug startup-view) - (let [component (case (if true startup-view :chat) + (let [current-view (validate-current-view @view-id @signed-up?)] + (log/debug current-view) + (let [component (case current-view :discovery main-tabs :discovery-tag discovery-tag :discovery-search-results discovery-search-results diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index 1052ba3a25..459fbfab3b 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -193,10 +193,10 @@ (fn [db _] (init-console-chat db false))) -(register-handler :save-password - (fn [db [_ _ mnemonic]] - (sign-up-service/passpharse-messages mnemonic) - (assoc db :password-saved true))) +(register-handler :show-mnemonic + (u/side-effect! + (fn [_ [_ mnemonic]] + (sign-up-service/passpharse-messages mnemonic)))) (register-handler :sign-up (after (fn [_ [_ phone-number]] diff --git a/src/status_im/db.cljs b/src/status_im/db.cljs index ec09eeffd4..60949ea6dd 100644 --- a/src/status_im/db.cljs +++ b/src/status_im/db.cljs @@ -7,7 +7,7 @@ ;; schema of app-db (def schema {:greeting s/Str}) -(def default-view :chat-list) +(def default-view :chat) ;; initial state of app-db (def app-db {:identity-password "replace-me-with-user-entered-password" diff --git a/src/status_im/discovery/handlers.cljs b/src/status_im/discovery/handlers.cljs index 751f91e633..0c2ec1efa3 100644 --- a/src/status_im/discovery/handlers.cljs +++ b/src/status_im/discovery/handlers.cljs @@ -5,6 +5,7 @@ [status-im.protocol.core :as protocol] [status-im.navigation.handlers :as nav] [status-im.data-store.discovery :as discoveries] + [status-im.data-store.contacts :as contacts] [status-im.utils.handlers :as u] [status-im.utils.datetime :as time] [status-im.utils.random :as random])) @@ -52,7 +53,7 @@ (register-handler :check-status! (u/side-effect! (fn [db [_ {:keys [whisper-identity status]} payload]] - (let [{old-status :status} (contacts/get-contact whisper-identity)] + (let [{old-status :status} (contacts/get-by-id whisper-identity)] (when (not= old-status status) (let [hashtags (get-hashtags status)] (when-not (empty? hashtags) diff --git a/src/status_im/translations/en.cljs b/src/status_im/translations/en.cljs index 305c2202ae..723737eeec 100644 --- a/src/status_im/translations/en.cljs +++ b/src/status_im/translations/en.cljs @@ -71,9 +71,6 @@ :confirmation-code (str "Thanks! We've sent you a text message with a confirmation " "code. Please provide that code to confirm your phone number") :incorrect-code (str "Sorry the code was incorrect, please enter again") - :password-saved (str "OK great! Your password has been saved. Just to let you " - "know you can always change it in the Console by the way " - "it's me the Console nice to meet you!") :generate-passphrase (str "I'll generate a passphrase for you so you can restore your " "access or log in from another device") :here-is-your-passphrase "Here is your passphrase, *write this down and keep this safe!* You will need it to recover your account."