fix #280
This commit is contained in:
parent
162952fcd2
commit
1464bd97f1
|
@ -43,9 +43,9 @@
|
||||||
(log/debug "account-created")
|
(log/debug "account-created")
|
||||||
(when (not (str/blank? public-key))
|
(when (not (str/blank? public-key))
|
||||||
(do
|
(do
|
||||||
(dispatch-sync [:add-account account])
|
(dispatch [:add-account account])
|
||||||
(dispatch-sync [:save-password password mnemonic])
|
(dispatch [:show-mnemonic mnemonic])
|
||||||
(dispatch-sync [:login-account address password])))))
|
(dispatch [:login-account address password])))))
|
||||||
|
|
||||||
(register-handler :create-account
|
(register-handler :create-account
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
|
@ -96,9 +96,8 @@
|
||||||
(defn set-current-account
|
(defn set-current-account
|
||||||
[{:keys [accounts] :as db} [_ address]]
|
[{:keys [accounts] :as db} [_ address]]
|
||||||
(let [key (:public-key (accounts address))]
|
(let [key (:public-key (accounts address))]
|
||||||
(-> db
|
(assoc db :current-account-id address
|
||||||
(assoc :current-account-id address)
|
:current-public-key key)))
|
||||||
(assoc :current-public-key key))))
|
|
||||||
|
|
||||||
(register-handler :set-current-account set-current-account)
|
(register-handler :set-current-account set-current-account)
|
||||||
|
|
||||||
|
@ -107,7 +106,10 @@
|
||||||
(map (fn [{:keys [address] :as account}]
|
(map (fn [{:keys [address] :as account}]
|
||||||
[address account]))
|
[address account]))
|
||||||
(into {}))]
|
(into {}))]
|
||||||
(assoc db :accounts accounts)))
|
(assoc db :accounts accounts
|
||||||
|
:view-id (if (empty? accounts)
|
||||||
|
:chat
|
||||||
|
:accounts))))
|
||||||
|
|
||||||
(register-handler :load-accounts load-accounts!)
|
(register-handler :load-accounts load-accounts!)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
(dispatch [:navigate-to :chat console-chat-id]))
|
(dispatch [:navigate-to :chat console-chat-id]))
|
||||||
(do
|
(do
|
||||||
(dispatch [:navigate-to-clean :accounts])
|
(dispatch [:navigate-to-clean :accounts])
|
||||||
(dispatch [:navigate-to default-view]))))
|
(dispatch [:navigate-to :chat-list]))))
|
||||||
|
|
||||||
(register-handler
|
(register-handler
|
||||||
:change-account
|
:change-account
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
[db address]
|
[db address]
|
||||||
(let [is-login-screen? (= (:view-id db) :login)
|
(let [is-login-screen? (= (:view-id db) :login)
|
||||||
new-account? (not is-login-screen?)]
|
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])))
|
(dispatch [:change-account address new-account? on-account-changed])))
|
||||||
|
|
||||||
(register-handler
|
(register-handler
|
||||||
|
|
|
@ -44,8 +44,15 @@
|
||||||
(defn orientation->keyword [o]
|
(defn orientation->keyword [o]
|
||||||
(keyword (.toLowerCase 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 []
|
(defn app-root []
|
||||||
(let [signed-up (subscribe [:signed-up?])
|
(let [signed-up? (subscribe [:signed-up?])
|
||||||
view-id (subscribe [:get :view-id])
|
view-id (subscribe [:get :view-id])
|
||||||
account-id (subscribe [:get :current-account-id])
|
account-id (subscribe [:get :current-account-id])
|
||||||
keyboard-height (subscribe [:get :keyboard-height])]
|
keyboard-height (subscribe [:get :keyboard-height])]
|
||||||
|
@ -71,17 +78,9 @@
|
||||||
(dispatch [:set :keyboard-height 0]))))
|
(dispatch [:set :keyboard-height 0]))))
|
||||||
:render
|
:render
|
||||||
(fn []
|
(fn []
|
||||||
(let [startup-view (if @account-id
|
(let [current-view (validate-current-view @view-id @signed-up?)]
|
||||||
(if @signed-up
|
(log/debug current-view)
|
||||||
@view-id
|
(let [component (case current-view
|
||||||
(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)
|
|
||||||
:discovery main-tabs
|
:discovery main-tabs
|
||||||
:discovery-tag discovery-tag
|
:discovery-tag discovery-tag
|
||||||
:discovery-search-results discovery-search-results
|
:discovery-search-results discovery-search-results
|
||||||
|
|
|
@ -193,10 +193,10 @@
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(init-console-chat db false)))
|
(init-console-chat db false)))
|
||||||
|
|
||||||
(register-handler :save-password
|
(register-handler :show-mnemonic
|
||||||
(fn [db [_ _ mnemonic]]
|
(u/side-effect!
|
||||||
(sign-up-service/passpharse-messages mnemonic)
|
(fn [_ [_ mnemonic]]
|
||||||
(assoc db :password-saved true)))
|
(sign-up-service/passpharse-messages mnemonic))))
|
||||||
|
|
||||||
(register-handler :sign-up
|
(register-handler :sign-up
|
||||||
(after (fn [_ [_ phone-number]]
|
(after (fn [_ [_ phone-number]]
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
;; schema of app-db
|
;; schema of app-db
|
||||||
(def schema {:greeting s/Str})
|
(def schema {:greeting s/Str})
|
||||||
|
|
||||||
(def default-view :chat-list)
|
(def default-view :chat)
|
||||||
|
|
||||||
;; initial state of app-db
|
;; initial state of app-db
|
||||||
(def app-db {:identity-password "replace-me-with-user-entered-password"
|
(def app-db {:identity-password "replace-me-with-user-entered-password"
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
[status-im.protocol.core :as protocol]
|
[status-im.protocol.core :as protocol]
|
||||||
[status-im.navigation.handlers :as nav]
|
[status-im.navigation.handlers :as nav]
|
||||||
[status-im.data-store.discovery :as discoveries]
|
[status-im.data-store.discovery :as discoveries]
|
||||||
|
[status-im.data-store.contacts :as contacts]
|
||||||
[status-im.utils.handlers :as u]
|
[status-im.utils.handlers :as u]
|
||||||
[status-im.utils.datetime :as time]
|
[status-im.utils.datetime :as time]
|
||||||
[status-im.utils.random :as random]))
|
[status-im.utils.random :as random]))
|
||||||
|
@ -52,7 +53,7 @@
|
||||||
(register-handler :check-status!
|
(register-handler :check-status!
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [db [_ {:keys [whisper-identity status]} payload]]
|
(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)
|
(when (not= old-status status)
|
||||||
(let [hashtags (get-hashtags status)]
|
(let [hashtags (get-hashtags status)]
|
||||||
(when-not (empty? hashtags)
|
(when-not (empty? hashtags)
|
||||||
|
|
|
@ -71,9 +71,6 @@
|
||||||
:confirmation-code (str "Thanks! We've sent you a text message with a confirmation "
|
:confirmation-code (str "Thanks! We've sent you a text message with a confirmation "
|
||||||
"code. Please provide that code to confirm your phone number")
|
"code. Please provide that code to confirm your phone number")
|
||||||
:incorrect-code (str "Sorry the code was incorrect, please enter again")
|
: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 "
|
:generate-passphrase (str "I'll generate a passphrase for you so you can restore your "
|
||||||
"access or log in from another device")
|
"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."
|
:here-is-your-passphrase "Here is your passphrase, *write this down and keep this safe!* You will need it to recover your account."
|
||||||
|
|
Loading…
Reference in New Issue