From 8cd77653f4f5c6a251845e6ad8322d5d153f2d6a Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Tue, 24 Apr 2018 18:31:18 +0200 Subject: [PATCH] fix cyclic deps related to status-im.transport.message.v1.* namespaces; move account-update to sparate ns; fix a few more cyclic deps; --- src/status_im/chat/events/console.cljs | 4 +- src/status_im/chat/events/requests.cljs | 3 +- src/status_im/chat/models.cljs | 3 +- src/status_im/transport/core.cljs | 11 +- src/status_im/transport/handlers.cljs | 104 +++++++++++++++++- .../transport/message/v1/contact.cljs | 74 ++----------- .../transport/message/v1/group_chat.cljs | 49 +-------- .../transport/message/v1/protocol.cljs | 1 - .../transport/message/v1/public_chat.cljs | 29 ++--- src/status_im/transport/utils.cljs | 8 ++ src/status_im/ui/screens/accounts/events.cljs | 27 +---- src/status_im/ui/screens/accounts/utils.cljs | 20 ++++ .../ui/screens/network_settings/events.cljs | 14 +-- src/status_im/ui/screens/profile/events.cljs | 6 +- .../ui/screens/usage_data/events.cljs | 4 +- 15 files changed, 184 insertions(+), 173 deletions(-) create mode 100644 src/status_im/ui/screens/accounts/utils.cljs diff --git a/src/status_im/chat/events/console.cljs b/src/status_im/chat/events/console.cljs index d94162ebbd..5ceecfd943 100644 --- a/src/status_im/chat/events/console.cljs +++ b/src/status_im/chat/events/console.cljs @@ -2,7 +2,7 @@ (:require [status-im.constants :as constants] [status-im.i18n :as i18n] [status-im.chat.console :as console-chat] - [status-im.ui.screens.accounts.events :as accounts-events] + [status-im.ui.screens.accounts.utils :as account.utils] [taoensso.timbre :as log] [status-im.i18n :as i18n] [goog.string :as gstring] @@ -67,7 +67,7 @@ :content (i18n/label :t/debug-enabled) :content-type constants/text-content-type})]] [[:stop-debugging]])} - (accounts-events/account-update {:debug? debug? + (account.utils/account-update {:debug? debug? :last-updated now}))))}) (def commands-names (set (keys console-commands->fx))) diff --git a/src/status_im/chat/events/requests.cljs b/src/status_im/chat/events/requests.cljs index a69c6d20c7..55f22e5a00 100644 --- a/src/status_im/chat/events/requests.cljs +++ b/src/status_im/chat/events/requests.cljs @@ -1,7 +1,6 @@ (ns status-im.chat.events.requests (:require [re-frame.core :as re-frame] - [status-im.constants :as constants] - [status-im.utils.handlers :as handlers])) + [status-im.constants :as constants])) ;; Functions diff --git a/src/status_im/chat/models.cljs b/src/status_im/chat/models.cljs index 97b66289f0..da4e9f039e 100644 --- a/src/status_im/chat/models.cljs +++ b/src/status_im/chat/models.cljs @@ -1,7 +1,6 @@ (ns status-im.chat.models (:require [status-im.ui.components.styles :as styles] - [status-im.utils.gfycat.core :as gfycat] - [status-im.utils.handlers :as handlers])) + [status-im.utils.gfycat.core :as gfycat])) (defn set-chat-ui-props "Updates ui-props in active chat by merging provided kvs into them" diff --git a/src/status_im/transport/core.cljs b/src/status_im/transport/core.cljs index c36b297854..0c897d82c0 100644 --- a/src/status_im/transport/core.cljs +++ b/src/status_im/transport/core.cljs @@ -10,7 +10,8 @@ [status-im.transport.inbox :as inbox] [status-im.utils.handlers :as handlers] [status-im.utils.handlers-macro :as handlers-macro] - [status-im.transport.db :as transport.db])) + [status-im.transport.db :as transport.db] + [status-im.transport.utils :as transport.utils])) (defn init-whisper "Initialises whisper protocol by: @@ -61,13 +62,7 @@ (fn [js-error js-message] (re-frame/dispatch [:protocol/receive-whisper-message js-error js-message chat-id]))))) -(defn unsubscribe-from-chat - "Unsubscribe from chat on transport layer" - [chat-id {:keys [db]}] - (let [filter (get-in db [:transport/chats chat-id :filter])] - {:db (update db :transport/chats dissoc chat-id) - :data-store.transport/delete chat-id - :shh/remove-filter filter})) +(def unsubscribe-from-chat transport.utils/unsubscribe-from-chat) (defn stop-whisper "Stops whisper protocol by removing all existing shh filters diff --git a/src/status_im/transport/handlers.cljs b/src/status_im/transport/handlers.cljs index e7336bccd7..82df33d3cb 100644 --- a/src/status_im/transport/handlers.cljs +++ b/src/status_im/transport/handlers.cljs @@ -11,7 +11,11 @@ [cljs.reader :as reader] [status-im.transport.message.transit :as transit] [status-im.transport.shh :as shh] - [status-im.transport.filters :as filters])) + [status-im.transport.filters :as filters] + [status-im.transport.message.core :as message] + [status-im.utils.handlers-macro :as handlers-macro] + [status-im.transport.message.v1.contact :as v1.contact] + [status-im.transport.message.v1.group-chat :as v1.group-chat])) (handlers/register-handler-fx :protocol/receive-whisper-message @@ -35,3 +39,101 @@ [re-frame/trim-v] (fn [{:keys [db] :as cofx} [err]] (log/error :send-status-message-error err))) + +(handlers/register-handler-fx + :contact/send-new-sym-key + (fn [{:keys [db random-id] :as cofx} [_ {:keys [chat-id topic message sym-key sym-key-id]}]] + (let [{:keys [web3 current-public-key]} db + chat-transport-info (-> (get-in db [:transport/chats chat-id]) + (assoc :sym-key-id sym-key-id) + ;;TODO (yenda) remove once go implements persistence + (assoc :sym-key sym-key))] + (handlers-macro/merge-fx cofx + {:db (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id) + :shh/add-filter {:web3 web3 + :sym-key-id sym-key-id + :topic topic + :chat-id chat-id} + :data-store.transport/save {:chat-id chat-id + :chat chat-transport-info}} + (message/send (v1.contact/NewContactKey. sym-key topic message) + chat-id))))) + +(handlers/register-handler-fx + :contact/add-new-sym-key + (fn [{:keys [db] :as cofx} [_ {:keys [sym-key-id sym-key chat-id topic message]}]] + (let [{:keys [web3 current-public-key]} db + chat-transport-info (-> (get-in db [:transport/chats chat-id]) + (assoc :sym-key-id sym-key-id) + ;;TODO (yenda) remove once go implements persistence + (assoc :sym-key sym-key))] + (handlers-macro/merge-fx cofx + {:db (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id) + :shh/add-filter {:web3 web3 + :sym-key-id sym-key-id + :topic topic + :chat-id chat-id} + :data-store.transport/save {:chat-id chat-id + :chat chat-transport-info}} + (message/receive message chat-id chat-id))))) + +#_(handlers/register-handler-fx + :send-test-message + (fn [cofx [this timer chat-id n]] + (if (zero? n) + (println "Time: " (str (- (inst-ms (js/Date.)) @timer))) + (handlers-macro/merge-fx cofx + {:dispatch [this timer chat-id (dec n)]} + (message/send (protocol/map->Message {:content (str n) + :content-type "text/plain" + :message-type :user-message + :clock-value n + :timestamp (str (inst-ms (js/Date.)))}) + chat-id))))) + + +(handlers/register-handler-fx + :group/unsubscribe-from-chat + [re-frame/trim-v] + (fn [cofx [chat-id]] + (transport/unsubscribe-from-chat chat-id cofx))) + +(handlers/register-handler-fx + :group/send-new-sym-key + [re-frame/trim-v] + ;; this is the event that is called when we want to send a message that required first + ;; some async operations + (fn [{:keys [db] :as cofx} [{:keys [chat-id message sym-key sym-key-id]}]] + (let [{:keys [web3]} db] + (handlers-macro/merge-fx cofx + {:db (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id) + :shh/add-filter {:web3 web3 + :sym-key-id sym-key-id + :topic (transport.utils/get-topic chat-id) + :chat-id chat-id} + :data-store.transport/save {:chat-id chat-id + :chat (-> (get-in db [:transport/chats chat-id]) + (assoc :sym-key-id sym-key-id) + ;;TODO (yenda) remove once go implements persistence + (assoc :sym-key sym-key))}} + (message/send (v1.group-chat/NewGroupKey. chat-id sym-key message) chat-id))))) + +(handlers/register-handler-fx + :group/add-new-sym-key + [re-frame/trim-v (re-frame/inject-cofx :random-id)] + (fn [{:keys [db] :as cofx} [{:keys [sym-key-id sym-key chat-id signature message]}]] + (let [{:keys [web3 current-public-key]} db + fx {:db (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id) + :shh/add-filter {:web3 web3 + :sym-key-id sym-key-id + :topic (transport.utils/get-topic chat-id) + :chat-id chat-id} + :data-store.transport/save {:chat-id chat-id + :chat (-> (get-in db [:transport/chats chat-id]) + (assoc :sym-key-id sym-key-id) + ;;TODO (yenda) remove once go implements persistence + (assoc :sym-key sym-key))}}] + ;; if new sym-key is wrapping some message, call receive on it as well, if not just update the transport layer + (if message + (handlers-macro/merge-fx cofx fx (message/receive message chat-id signature)) + fx)))) diff --git a/src/status_im/transport/message/v1/contact.cljs b/src/status_im/transport/message/v1/contact.cljs index a5a6438db1..d0e1dac6eb 100644 --- a/src/status_im/transport/message/v1/contact.cljs +++ b/src/status_im/transport/message/v1/contact.cljs @@ -5,7 +5,6 @@ [status-im.transport.message.v1.protocol :as protocol] [status-im.transport.utils :as transport.utils] [status-im.ui.screens.contacts.core :as contacts] - [status-im.utils.handlers :as handlers] [status-im.utils.handlers-macro :as handlers-macro])) (defrecord NewContactKey [sym-key topic message] @@ -16,11 +15,12 @@ cofx)) (receive [this chat-id signature cofx] (let [on-success (fn [sym-key sym-key-id] - (re-frame/dispatch [::add-new-sym-key {:sym-key-id sym-key-id - :sym-key sym-key - :chat-id chat-id - :topic topic - :message message}]))] + (re-frame/dispatch [:contact/add-new-sym-key + {:sym-key-id sym-key-id + :sym-key sym-key + :chat-id chat-id + :topic topic + :message message}]))] (handlers-macro/merge-fx cofx {:shh/add-new-sym-key {:web3 (get-in cofx [:db :web3]) :sym-key sym-key @@ -33,11 +33,12 @@ (let [message-id (transport.utils/message-id this) topic (transport.utils/get-topic random-id) on-success (fn [sym-key sym-key-id] - (re-frame/dispatch [::send-new-sym-key {:sym-key-id sym-key-id - :sym-key sym-key - :chat-id chat-id - :topic topic - :message this}]))] + (re-frame/dispatch [:contact/send-new-sym-key + {:sym-key-id sym-key-id + :sym-key sym-key + :chat-id chat-id + :topic topic + :message this}]))] (handlers-macro/merge-fx cofx {:shh/get-new-sym-key {:web3 (:web3 db) :on-success on-success}} @@ -82,54 +83,3 @@ (contacts/receive-contact-update chat-id signature this)))))) - -(handlers/register-handler-fx - ::send-new-sym-key - (fn [{:keys [db random-id] :as cofx} [_ {:keys [chat-id topic message sym-key sym-key-id]}]] - (let [{:keys [web3 current-public-key]} db - chat-transport-info (-> (get-in db [:transport/chats chat-id]) - (assoc :sym-key-id sym-key-id) - ;;TODO (yenda) remove once go implements persistence - (assoc :sym-key sym-key))] - (handlers-macro/merge-fx cofx - {:db (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id) - :shh/add-filter {:web3 web3 - :sym-key-id sym-key-id - :topic topic - :chat-id chat-id} - :data-store.transport/save {:chat-id chat-id - :chat chat-transport-info}} - (message/send (NewContactKey. sym-key topic message) - chat-id))))) - -(handlers/register-handler-fx - ::add-new-sym-key - (fn [{:keys [db] :as cofx} [_ {:keys [sym-key-id sym-key chat-id topic message]}]] - (let [{:keys [web3 current-public-key]} db - chat-transport-info (-> (get-in db [:transport/chats chat-id]) - (assoc :sym-key-id sym-key-id) - ;;TODO (yenda) remove once go implements persistence - (assoc :sym-key sym-key))] - (handlers-macro/merge-fx cofx - {:db (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id) - :shh/add-filter {:web3 web3 - :sym-key-id sym-key-id - :topic topic - :chat-id chat-id} - :data-store.transport/save {:chat-id chat-id - :chat chat-transport-info}} - (message/receive message chat-id chat-id))))) - -#_(handlers/register-handler-fx - :send-test-message - (fn [cofx [this timer chat-id n]] - (if (zero? n) - (println "Time: " (str (- (inst-ms (js/Date.)) @timer))) - (handlers-macro/merge-fx cofx - {:dispatch [this timer chat-id (dec n)]} - (message/send (protocol/map->Message {:content (str n) - :content-type "text/plain" - :message-type :user-message - :clock-value n - :timestamp (str (inst-ms (js/Date.)))}) - chat-id))))) diff --git a/src/status_im/transport/message/v1/group_chat.cljs b/src/status_im/transport/message/v1/group_chat.cljs index 30ecc3bb72..8add24db26 100644 --- a/src/status_im/transport/message/v1/group_chat.cljs +++ b/src/status_im/transport/message/v1/group_chat.cljs @@ -2,14 +2,12 @@ status-im.transport.message.v1.group-chat (:require [clojure.set :as set] [re-frame.core :as re-frame] - [status-im.utils.handlers :as handlers] [status-im.utils.handlers-macro :as handlers-macro] [status-im.transport.message.core :as message] [status-im.i18n :as i18n] [status-im.ui.screens.group.core :as group] [status-im.chat.models :as models.chat] [status-im.chat.models.message :as models.message] - [status-im.transport.core :as transport] [status-im.transport.message.v1.protocol :as protocol] [status-im.transport.utils :as transport.utils])) @@ -100,7 +98,7 @@ (models.chat/upsert-chat {:chat-id chat-id :removed-from-at now :is-active false}) - (transport/unsubscribe-from-chat chat-id)) + (transport.utils/unsubscribe-from-chat chat-id)) (handlers-macro/merge-fx cofx (models.message/receive (models.message/system-message chat-id random-id now @@ -133,48 +131,3 @@ (group/participants-removed chat-id #{signature}) (send-new-group-key nil chat-id)))))) -(handlers/register-handler-fx - ::unsubscribe-from-chat - [re-frame/trim-v] - (fn [cofx [chat-id]] - (transport/unsubscribe-from-chat chat-id cofx))) - -(handlers/register-handler-fx - ::send-new-sym-key - [re-frame/trim-v] - ;; this is the event that is called when we want to send a message that required first - ;; some async operations - (fn [{:keys [db] :as cofx} [{:keys [chat-id message sym-key sym-key-id]}]] - (let [{:keys [web3]} db] - (handlers-macro/merge-fx cofx - {:db (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id) - :shh/add-filter {:web3 web3 - :sym-key-id sym-key-id - :topic (transport.utils/get-topic chat-id) - :chat-id chat-id} - :data-store.transport/save {:chat-id chat-id - :chat (-> (get-in db [:transport/chats chat-id]) - (assoc :sym-key-id sym-key-id) - ;;TODO (yenda) remove once go implements persistence - (assoc :sym-key sym-key))}} - (message/send (NewGroupKey. chat-id sym-key message) chat-id))))) - -(handlers/register-handler-fx - ::add-new-sym-key - [re-frame/trim-v (re-frame/inject-cofx :random-id)] - (fn [{:keys [db] :as cofx} [{:keys [sym-key-id sym-key chat-id signature message]}]] - (let [{:keys [web3 current-public-key]} db - fx {:db (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id) - :shh/add-filter {:web3 web3 - :sym-key-id sym-key-id - :topic (transport.utils/get-topic chat-id) - :chat-id chat-id} - :data-store.transport/save {:chat-id chat-id - :chat (-> (get-in db [:transport/chats chat-id]) - (assoc :sym-key-id sym-key-id) - ;;TODO (yenda) remove once go implements persistence - (assoc :sym-key sym-key))}}] - ;; if new sym-key is wrapping some message, call receive on it as well, if not just update the transport layer - (if message - (handlers-macro/merge-fx cofx fx (message/receive message chat-id signature)) - fx)))) diff --git a/src/status_im/transport/message/v1/protocol.cljs b/src/status_im/transport/message/v1/protocol.cljs index 641a4b459f..499626d97d 100644 --- a/src/status_im/transport/message/v1/protocol.cljs +++ b/src/status_im/transport/message/v1/protocol.cljs @@ -5,7 +5,6 @@ [status-im.chat.core :as chat] [status-im.transport.message-cache :as message-cache] [status-im.transport.db :as transport.db] - [status-im.transport.core :as transport] [status-im.transport.message.core :as message] [status-im.transport.utils :as transport.utils])) diff --git a/src/status_im/transport/message/v1/public_chat.cljs b/src/status_im/transport/message/v1/public_chat.cljs index b6950b4ca8..18e9962d92 100644 --- a/src/status_im/transport/message/v1/public_chat.cljs +++ b/src/status_im/transport/message/v1/public_chat.cljs @@ -25,17 +25,18 @@ (protocol/init-chat chat-id))))) (handlers/register-handler-fx - ::add-new-sym-key - (fn [{:keys [db] :as cofx} [_ {:keys [sym-key-id sym-key chat-id]}]] - (let [{:keys [web3]} db] - (handlers-macro/merge-fx cofx - {:db (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id) - :shh/add-filter {:web3 web3 - :sym-key-id sym-key-id - :topic (transport.utils/get-topic chat-id) - :chat-id chat-id} - :data-store.transport/save {:chat-id chat-id - :chat (-> (get-in db [:transport/chats chat-id]) - (assoc :sym-key-id sym-key-id) - ;;TODO (yenda) remove once go implements persistence - (assoc :sym-key sym-key))}})))) + ::add-new-sym-key + (fn [{:keys [db] :as cofx} [_ {:keys [sym-key-id sym-key chat-id]}]] + (let [{:keys [web3]} db] + (handlers-macro/merge-fx + cofx + {:db (assoc-in db [:transport/chats chat-id :sym-key-id] sym-key-id) + :shh/add-filter {:web3 web3 + :sym-key-id sym-key-id + :topic (transport.utils/get-topic chat-id) + :chat-id chat-id} + :data-store.transport/save {:chat-id chat-id + :chat (-> (get-in db [:transport/chats chat-id]) + (assoc :sym-key-id sym-key-id) + ;;TODO (yenda) remove once go implements persistence + (assoc :sym-key sym-key))}})))) diff --git a/src/status_im/transport/utils.cljs b/src/status_im/transport/utils.cljs index 4d57a55cac..6fb3d49a4d 100644 --- a/src/status_im/transport/utils.cljs +++ b/src/status_im/transport/utils.cljs @@ -5,6 +5,14 @@ [clojure.string :as string] [status-im.js-dependencies :as dependencies])) +(defn unsubscribe-from-chat + "Unsubscribe from chat on transport layer" + [chat-id {:keys [db]}] + (let [filter (get-in db [:transport/chats chat-id :filter])] + {:db (update db :transport/chats dissoc chat-id) + :data-store.transport/delete chat-id + :shh/remove-filter filter})) + (defn from-utf8 [s] (.fromUtf8 dependencies/Web3.prototype s)) diff --git a/src/status_im/ui/screens/accounts/events.cljs b/src/status_im/ui/screens/accounts/events.cljs index 73000306f0..7f3e3166c8 100644 --- a/src/status_im/ui/screens/accounts/events.cljs +++ b/src/status_im/ui/screens/accounts/events.cljs @@ -14,10 +14,10 @@ [status-im.utils.gfycat.core :refer [generate-gfy]] [status-im.utils.hex :as utils.hex] [status-im.constants :as constants] - [status-im.transport.message.v1.contact :as message.contact] [status-im.transport.message.core :as transport] status-im.ui.screens.accounts.create.navigation - [status-im.chat.models :as chat.models])) + [status-im.chat.models :as chat.models] + [status-im.ui.screens.accounts.utils :as accounts.utils])) ;;;; COFX @@ -111,21 +111,6 @@ {:db (assoc db :account/account new-account) :data-store/save-account new-account})) -(defn account-update - "Takes effects (containing :db) + new account fields, adds all effects necessary for account update. - Optionally, one can specify event to be dispatched after fields are persisted." - ([new-account-fields cofx] - (account-update new-account-fields nil cofx)) - ([new-account-fields after-update-event {:keys [db] :as cofx}] - (let [current-account (:account/account db) - new-account (merge current-account new-account-fields) - fx {:db (assoc db :account/account new-account) - :data-store/save-account (assoc new-account :after-update-event after-update-event)} - {:keys [name photo-path]} new-account] - (if (or (:name new-account-fields) (:photo-path new-account-fields)) - (handlers-macro/merge-fx cofx fx (transport/send (message.contact/ContactUpdate. name photo-path) nil)) - fx)))) - (handlers/register-handler-fx :send-account-update-if-needed (fn [{:keys [db now] :as cofx} _] @@ -135,7 +120,7 @@ (when needs-update? ;; TODO(janherich): this is very strange and misleading, need to figure out why it'd necessary to update ;; account with network update when last update was more then week ago - (account-update nil cofx))))) + (accounts.utils/account-update nil cofx))))) (handlers/register-handler-fx :account-set-name @@ -143,7 +128,7 @@ (handlers-macro/merge-fx cofx {:db (assoc-in db [:accounts/create :show-welcome?] true) :dispatch [:navigate-to-clean :usage-data [:account-finalized]]} - (account-update {:name (:name create)})))) + (accounts.utils/account-update {:name (:name create)})))) (handlers/register-handler-fx :account-finalized @@ -160,7 +145,7 @@ (handlers/register-handler-fx :update-sign-in-time (fn [{db :db now :now :as cofx} _] - (account-update {:last-sign-in now} cofx))) + (accounts.utils/account-update {:last-sign-in now} cofx))) (handlers/register-handler-fx :reset-account-creation @@ -170,4 +155,4 @@ (handlers/register-handler-fx :switch-dev-mode (fn [cofx [_ dev-mode]] - (account-update {:dev-mode? dev-mode} cofx))) + (accounts.utils/account-update {:dev-mode? dev-mode} cofx))) diff --git a/src/status_im/ui/screens/accounts/utils.cljs b/src/status_im/ui/screens/accounts/utils.cljs new file mode 100644 index 0000000000..d9f6f5a434 --- /dev/null +++ b/src/status_im/ui/screens/accounts/utils.cljs @@ -0,0 +1,20 @@ +(ns status-im.ui.screens.accounts.utils + (:require [status-im.transport.message.core :as transport] + [status-im.utils.handlers-macro :as handlers-macro] + [status-im.transport.message.v1.contact :as message.contact])) + + +(defn account-update + "Takes effects (containing :db) + new account fields, adds all effects necessary for account update. + Optionally, one can specify event to be dispatched after fields are persisted." + ([new-account-fields cofx] + (account-update new-account-fields nil cofx)) + ([new-account-fields after-update-event {{:accounts/keys [accounts current-account-id] :as db} :db :as cofx}] + (let [current-account (get accounts current-account-id) + new-account (merge current-account new-account-fields) + fx {:db (assoc-in db [:accounts/accounts current-account-id] new-account) + :data-store/save-account (assoc new-account :after-update-event after-update-event)} + {:keys [name photo-path]} new-account] + (if (or (:name new-account-fields) (:photo-path new-account-fields)) + (handlers-macro/merge-fx cofx fx (transport/send (message.contact/ContactUpdate. name photo-path) nil)) + fx)))) diff --git a/src/status_im/ui/screens/network_settings/events.cljs b/src/status_im/ui/screens/network_settings/events.cljs index 3e1e1ded1d..f05be6bd45 100644 --- a/src/status_im/ui/screens/network_settings/events.cljs +++ b/src/status_im/ui/screens/network_settings/events.cljs @@ -2,7 +2,7 @@ (: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-macro :as handlers-macro] - [status-im.ui.screens.accounts.events :as accounts-events] + [status-im.ui.screens.accounts.utils :as accounts.utils] [status-im.i18n :as i18n] [status-im.utils.ethereum.core :as utils] [status-im.transport.core :as transport])) @@ -30,10 +30,10 @@ (handlers/register-handler-fx ::save-network (fn [{:keys [db now] :as cofx} [_ network]] - (handlers-macro/merge-fx cofx - (accounts-events/account-update {:network network - :last-updated now} - [::close-application])))) + (handlers-macro/merge-fx cofx + (accounts.utils/account-update {:network network + :last-updated now} + [::close-application])))) (handlers/register-handler-fx :connect-network @@ -46,8 +46,8 @@ {:dispatch-n [[:load-accounts] [:navigate-to-clean :accounts]]} (transport/stop-whisper) - (accounts-events/account-update {:network network - :last-updated now})) + (accounts.utils/account-update {:network network + :last-updated now})) {:show-confirmation {:title (i18n/label :t/close-app-title) :content (i18n/label :t/close-app-content) :confirm-button-text (i18n/label :t/close-app-button) diff --git a/src/status_im/ui/screens/profile/events.cljs b/src/status_im/ui/screens/profile/events.cljs index 6e0f5e4685..4358d0f9aa 100644 --- a/src/status_im/ui/screens/profile/events.cljs +++ b/src/status_im/ui/screens/profile/events.cljs @@ -4,7 +4,7 @@ [status-im.ui.components.react :refer [show-image-picker]] [status-im.chat.constants :as chat-const] [status-im.ui.screens.profile.navigation] - [status-im.ui.screens.accounts.events :as accounts-events] + [status-im.ui.screens.accounts.utils :as accounts.utils] [status-im.chat.events :as chat-events] [status-im.chat.events.input :as input-events] [status-im.utils.handlers :as handlers] @@ -80,7 +80,7 @@ {:photo-path photo-path}))] (handlers-macro/merge-fx cofx (clear-profile) - (accounts-events/account-update cleaned-edit))))) + (accounts.utils/account-update cleaned-edit))))) (handlers/register-handler-fx :group-chat-profile/start-editing @@ -112,4 +112,4 @@ (fn [{:keys [db] :as cofx} _] (handlers-macro/merge-fx cofx {:db (update db :my-profile/seed assoc :step :finish :error nil :word nil)} - (accounts-events/account-update {:seed-backed-up? true})))) + (accounts.utils/account-update {:seed-backed-up? true})))) diff --git a/src/status_im/ui/screens/usage_data/events.cljs b/src/status_im/ui/screens/usage_data/events.cljs index e73d47d29e..1234bf9ccb 100644 --- a/src/status_im/ui/screens/usage_data/events.cljs +++ b/src/status_im/ui/screens/usage_data/events.cljs @@ -1,9 +1,9 @@ (ns status-im.ui.screens.usage-data.events (:require [status-im.utils.handlers :as handlers] - [status-im.ui.screens.accounts.events :as accounts])) + [status-im.ui.screens.accounts.utils :as accounts.utils])) (handlers/register-handler-fx :help-improve-handler (fn [{db :db} [_ yes? next]] - (merge (accounts/account-update {:sharing-usage-data? yes?} {:db db}) + (merge (accounts.utils/account-update {:sharing-usage-data? yes?} {:db db}) {:dispatch (or next [:navigate-to-clean :home])})))