Merge pull request #326 from status-im/feature/on-boarding-console-#280

Make console the default on-boarding (#280)
This commit is contained in:
Roman Volosovskyi 2016-10-05 16:52:18 +03:00 committed by GitHub
commit 4d95c095ab
7 changed files with 28 additions and 29 deletions

View File

@ -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!)

View File

@ -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

View File

@ -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

View File

@ -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]]

View File

@ -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"

View File

@ -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]

View File

@ -75,9 +75,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."