use account-update function instead of dispatching :account-update (#1995)
* use account-update function instead of dispatching :account-update * add (inject-cofx :now) to default interceptors
This commit is contained in:
parent
7540dda41d
commit
2763c87c40
|
@ -113,7 +113,7 @@
|
||||||
;; TODO(janherich) remove this once send-message events are refactored
|
;; TODO(janherich) remove this once send-message events are refactored
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:invoke-console-command-handler!
|
:invoke-console-command-handler!
|
||||||
[re-frame/trim-v (re-frame/inject-cofx :random-id) (re-frame/inject-cofx :now)]
|
[re-frame/trim-v (re-frame/inject-cofx :random-id)]
|
||||||
(fn [cofx [{:keys [chat-id command] :as command-params}]]
|
(fn [cofx [{:keys [chat-id command] :as command-params}]]
|
||||||
(let [fx-fn (get console-commands->fx (-> command :command :name))]
|
(let [fx-fn (get console-commands->fx (-> command :command :name))]
|
||||||
(-> cofx
|
(-> cofx
|
||||||
|
|
|
@ -390,7 +390,7 @@
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:proceed-command
|
:proceed-command
|
||||||
[re-frame/trim-v (re-frame/inject-cofx :random-id) (re-frame/inject-cofx :now)]
|
[re-frame/trim-v (re-frame/inject-cofx :random-id)]
|
||||||
(fn [{:keys [db random-id now]} [content]]
|
(fn [{:keys [db random-id now]} [content]]
|
||||||
(proceed-command db content random-id now)))
|
(proceed-command db content random-id now)))
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:send-current-message
|
:send-current-message
|
||||||
[(re-frame/inject-cofx :random-id) (re-frame/inject-cofx :now)]
|
[(re-frame/inject-cofx :random-id)]
|
||||||
(fn [{{:keys [current-chat-id current-public-key] :as db} :db message-id :random-id current-time :now} _]
|
(fn [{{:keys [current-chat-id current-public-key] :as db} :db message-id :random-id current-time :now} _]
|
||||||
(let [input-text (get-in db [:chats current-chat-id :input-text])
|
(let [input-text (get-in db [:chats current-chat-id :input-text])
|
||||||
chat-command (-> db
|
chat-command (-> db
|
||||||
|
|
|
@ -105,7 +105,7 @@
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
::contacts-synced
|
::contacts-synced
|
||||||
[re-frame/trim-v (re-frame/inject-cofx :random-id) (re-frame/inject-cofx :now)]
|
[re-frame/trim-v (re-frame/inject-cofx :random-id)]
|
||||||
(fn [{:keys [db random-id] :as cofx} [contacts]]
|
(fn [{:keys [db random-id] :as cofx} [contacts]]
|
||||||
(-> db
|
(-> db
|
||||||
(contacts-events/add-contacts contacts)
|
(contacts-events/add-contacts contacts)
|
||||||
|
|
|
@ -177,13 +177,13 @@
|
||||||
;; TODO(janherich): remove this event once it's not used anymore
|
;; TODO(janherich): remove this event once it's not used anymore
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:account-update
|
:account-update
|
||||||
[(re-frame/inject-cofx :now) re-frame/trim-v]
|
[re-frame/trim-v]
|
||||||
(fn [cofx [new-account-fields]]
|
(fn [cofx [new-account-fields]]
|
||||||
(account-update cofx new-account-fields)))
|
(account-update cofx new-account-fields)))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:account-update-keys
|
:account-update-keys
|
||||||
[(re-frame/inject-cofx :get-new-keypair!) (re-frame/inject-cofx :now)]
|
[(re-frame/inject-cofx :get-new-keypair!)]
|
||||||
(fn [{:keys [db keypair now]} _]
|
(fn [{:keys [db keypair now]} _]
|
||||||
(let [{:accounts/keys [accounts current-account-id]} db
|
(let [{:accounts/keys [accounts current-account-id]} db
|
||||||
{:keys [public private]} keypair
|
{:keys [public private]} keypair
|
||||||
|
@ -200,7 +200,6 @@
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:send-account-update-if-needed
|
:send-account-update-if-needed
|
||||||
[(re-frame/inject-cofx :now)]
|
|
||||||
(fn [{{:accounts/keys [accounts current-account-id]} :db now :now :as cofx} _]
|
(fn [{{:accounts/keys [accounts current-account-id]} :db now :now :as cofx} _]
|
||||||
(let [{:keys [last-updated]} (get accounts current-account-id)
|
(let [{:keys [last-updated]} (get accounts current-account-id)
|
||||||
needs-update? (> (- now last-updated) time/week)]
|
needs-update? (> (- now last-updated) time/week)]
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
(:require [re-frame.core :refer [dispatch dispatch-sync after] :as re-frame]
|
(:require [re-frame.core :refer [dispatch dispatch-sync after] :as re-frame]
|
||||||
[status-im.utils.handlers :refer [register-handler] :as handlers]
|
[status-im.utils.handlers :refer [register-handler] :as handlers]
|
||||||
[status-im.data-store.networks :as networks]
|
[status-im.data-store.networks :as networks]
|
||||||
[status-im.ui.screens.network-settings.navigation]))
|
[status-im.ui.screens.network-settings.navigation]
|
||||||
|
[status-im.ui.screens.accounts.events :as accounts-events]))
|
||||||
|
|
||||||
;;;; FX
|
;;;; FX
|
||||||
|
|
||||||
|
@ -28,6 +29,6 @@
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:connect-network
|
:connect-network
|
||||||
(fn [_ [_ network]]
|
(fn [cofx [_ network]]
|
||||||
{:dispatch-n [[:account-update {:network network}]
|
(merge (accounts-events/account-update cofx {:network network})
|
||||||
[:navigate-to-clean :accounts]]}))
|
{:dispatch [:navigate-to-clean :accounts]})))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(ns status-im.utils.handlers
|
(ns status-im.utils.handlers
|
||||||
(:require [cljs.spec.alpha :as spec]
|
(:require [cljs.spec.alpha :as spec]
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[re-frame.core :refer [reg-event-db reg-event-fx]]
|
[re-frame.core :refer [reg-event-db reg-event-fx] :as re-frame]
|
||||||
[re-frame.interceptor :refer [->interceptor get-coeffect get-effect]]
|
[re-frame.interceptor :refer [->interceptor get-coeffect get-effect]]
|
||||||
[taoensso.timbre :as log])
|
[taoensso.timbre :as log])
|
||||||
(:require-macros status-im.utils.handlers))
|
(:require-macros status-im.utils.handlers))
|
||||||
|
@ -40,15 +40,18 @@
|
||||||
([name middleware handler]
|
([name middleware handler]
|
||||||
(reg-event-db name [debug-handlers-names (when js/goog.DEBUG check-spec) middleware] handler)))
|
(reg-event-db name [debug-handlers-names (when js/goog.DEBUG check-spec) middleware] handler)))
|
||||||
|
|
||||||
|
(def default-interceptors
|
||||||
|
[debug-handlers-names (when js/goog.DEBUG check-spec) (re-frame/inject-cofx :now)])
|
||||||
|
|
||||||
(defn register-handler-db
|
(defn register-handler-db
|
||||||
([name handler] (register-handler-db name nil handler))
|
([name handler] (register-handler-db name nil handler))
|
||||||
([name interceptors handler]
|
([name interceptors handler]
|
||||||
(reg-event-db name [debug-handlers-names (when js/goog.DEBUG check-spec) interceptors] handler)))
|
(reg-event-db name [default-interceptors interceptors] handler)))
|
||||||
|
|
||||||
(defn register-handler-fx
|
(defn register-handler-fx
|
||||||
([name handler] (register-handler-fx name nil handler))
|
([name handler] (register-handler-fx name nil handler))
|
||||||
([name interceptors handler]
|
([name interceptors handler]
|
||||||
(reg-event-fx name [debug-handlers-names (when js/goog.DEBUG check-spec) interceptors] handler)))
|
(reg-event-fx name [default-interceptors interceptors] handler)))
|
||||||
|
|
||||||
(defn get-hashtags [status]
|
(defn get-hashtags [status]
|
||||||
(if status
|
(if status
|
||||||
|
|
Loading…
Reference in New Issue