This commit is contained in:
Adrian Tiberius 2016-10-05 15:19:12 +03:00
parent 162952fcd2
commit 1464bd97f1
7 changed files with 29 additions and 30 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]))
@ -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)

View File

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