Fix some typos in develop
This commit is contained in:
parent
a995f73638
commit
40e006ef00
|
@ -50,22 +50,22 @@
|
|||
:message-status :seen})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:start-listening-confirmation-code-sms
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db]} [sms-listener]]
|
||||
{:db (if-not (:confirmation-code-sms-listener db)
|
||||
(assoc db :confirmation-code-sms-listener sms-listener)
|
||||
db)}))
|
||||
:start-listening-confirmation-code-sms
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db]} [sms-listener]]
|
||||
{:db (if-not (:confirmation-code-sms-listener db)
|
||||
(assoc db :confirmation-code-sms-listener sms-listener)
|
||||
db)}))
|
||||
|
||||
(defn stop-listening-confirmation-code-sms [{:keys [db] :as fx}]
|
||||
(-> fx
|
||||
(update db dissoc :confirmation-code-sms-listener)
|
||||
(update ::remove-sms-listener assoc (:confirmation-code-sms-listener db))))
|
||||
(update :db dissoc :confirmation-code-sms-listener)
|
||||
(assoc ::remove-sms-listener (:confirmation-code-sms-listener db))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::remove-sms-listener
|
||||
(fn [subscription]
|
||||
(sms-listener/remove-sms-listener subscription)))
|
||||
::remove-sms-listener
|
||||
(fn [subscription]
|
||||
(sms-listener/remove-sms-listener subscription)))
|
||||
|
||||
(defn- sms-receive-handler [{confirmation-code :body}]
|
||||
(when-let [matches (re-matches #"(\d{4})" confirmation-code)]
|
||||
|
@ -79,15 +79,15 @@
|
|||
(re-frame/dispatch [:start-listening-confirmation-code-sms listener])))])
|
||||
|
||||
(handlers/register-handler-fx
|
||||
::sign-up-success
|
||||
[re-frame/trim-v (re-frame/inject-cofx :random-id)]
|
||||
(fn [{:keys [db random-id]} message-id]
|
||||
(-> {:db db
|
||||
:dispatch-n [;; create manual way for entering confirmation code
|
||||
(sign-up/enter-confirmation-code-event random-id)
|
||||
;; create automatic way for receiving confirmation code
|
||||
start-listening-confirmation-code-sms-event]}
|
||||
(message-seen message-id))))
|
||||
::sign-up-success
|
||||
[re-frame/trim-v (re-frame/inject-cofx :random-id)]
|
||||
(fn [{:keys [db random-id]} [message-id]]
|
||||
(-> {:db db
|
||||
:dispatch-n [;; create manual way for entering confirmation code
|
||||
(sign-up/enter-confirmation-code-event random-id)
|
||||
;; create automatic way for receiving confirmation code
|
||||
start-listening-confirmation-code-sms-event]}
|
||||
(message-seen message-id))))
|
||||
|
||||
(defn- extract-last-phone-number [chats]
|
||||
(let [phone-message (->> (get-in chats ["console" :messages])
|
||||
|
@ -103,18 +103,15 @@
|
|||
(sign-up-confirm db confirmation-code message-id)))
|
||||
|
||||
(defn- sign-up-confirmed [{:keys [db] :as fx} now]
|
||||
(let [last-phone-number (extract-last-phone-number (:chats db))]
|
||||
(cond->
|
||||
(stop-listening-confirmation-code-sms fx)
|
||||
|
||||
true
|
||||
(update :dispatch-n conj [:request-permissions [:read-contacts]
|
||||
#(re-frame/dispatch [:sync-contacts (fn [contacts]
|
||||
[::contacts-synced contacts])])])
|
||||
|
||||
last-phone-number
|
||||
(accounts-events/account-update {:phone last-phone-number
|
||||
:last-updated now}))))
|
||||
(let [last-phone-number (extract-last-phone-number (:chats db))
|
||||
fx (-> (stop-listening-confirmation-code-sms fx)
|
||||
(update :dispatch-n conj
|
||||
[:request-permissions [:read-contacts]
|
||||
#(re-frame/dispatch [:sync-contacts (fn [contacts]
|
||||
[::contacts-synced contacts])])]))]
|
||||
(cond-> fx
|
||||
last-phone-number (accounts-events/account-update {:phone last-phone-number
|
||||
:last-updated now}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
::sign-up-confirm-response
|
||||
|
|
|
@ -31,14 +31,14 @@
|
|||
;;;; COFX
|
||||
|
||||
(re-frame/reg-cofx
|
||||
:get-new-keypair!
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects :keypair (protocol/new-keypair!))))
|
||||
:get-new-keypair!
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects :keypair (protocol/new-keypair!))))
|
||||
|
||||
(re-frame/reg-cofx
|
||||
::get-all-accounts
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects :all-accounts (accounts-store/get-all))))
|
||||
::get-all-accounts
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects :all-accounts (accounts-store/get-all))))
|
||||
|
||||
;;;; FX
|
||||
|
||||
|
@ -138,9 +138,9 @@
|
|||
;;workaround for realm bug, migrating account v4
|
||||
events (mapv #(when (empty? (:networks %)) [:account-update-networks (:address %)]) (vals accounts))]
|
||||
(merge
|
||||
{:db (assoc db :accounts/accounts accounts)}
|
||||
(when-not (empty? events)
|
||||
{:dispatch-n events})))))
|
||||
{:db (assoc db :accounts/accounts accounts)}
|
||||
(when-not (empty? events)
|
||||
{:dispatch-n events})))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:account-update-networks
|
||||
|
@ -162,18 +162,16 @@
|
|||
{:dispatch [:broadcast-status status hashtags]}))))))
|
||||
|
||||
(defn account-update
|
||||
"Takes map of coeffects containing `:db` and `:now` keys + new account fields,
|
||||
returns all effects necessary for account update."
|
||||
"Takes effects (containing :db) + new account fields, adds all effects necessary for account update."
|
||||
[{{:accounts/keys [accounts current-account-id] :as db} :db :as fx} new-account-fields]
|
||||
(let [current-account (get accounts current-account-id)
|
||||
new-account (merge current-account new-account-fields)]
|
||||
(-> fx
|
||||
(assoc-in [:db :accounts/accounts current-account-id] new-account)
|
||||
(assoc ::save-account new-account)
|
||||
(assoc ::broadcast-account-update (merge
|
||||
(select-keys db [:current-public-key :web3])
|
||||
(select-keys new-account [:name :photo-path :status
|
||||
:updates-public-key :updates-private-key]))))))
|
||||
(assoc ::save-account new-account
|
||||
::broadcast-account-update (merge (select-keys db [:current-public-key :web3])
|
||||
(select-keys new-account [:name :photo-path :status
|
||||
:updates-public-key :updates-private-key]))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:account-update-keys
|
||||
|
|
Loading…
Reference in New Issue