diff --git a/src/status_im/contact/core.cljs b/src/status_im/contact/core.cljs index 8e6a4b84dc..a06a1f6c3d 100644 --- a/src/status_im/contact/core.cljs +++ b/src/status_im/contact/core.cljs @@ -60,19 +60,9 @@ (multiaccounts.update/multiaccount-update :photo-path photo-path {:dont-sync? true})))) (fx/defn ensure-contact - [{:keys [db] :as cofx} + [{:keys [db]} {:keys [public-key] :as contact}] - (let [new? (get-in db [:contacts/contacts public-key]) - us? (= public-key (multiaccounts.model/current-public-key cofx))] - (fx/merge cofx - {:db (-> db - (update-in [:contacts/contacts public-key] merge contact))} - - (cond - us? - (handle-update-from-contact-request contact) - new? - (transport.filters/load-contact contact))))) + {:db (update-in db [:contacts/contacts public-key] merge contact)}) (fx/defn upsert-contact [{:keys [db] :as cofx} diff --git a/src/status_im/transport/message/core.cljs b/src/status_im/transport/message/core.cljs index 4e88c60d75..30c6c288cf 100644 --- a/src/status_im/transport/message/core.cljs +++ b/src/status_im/transport/message/core.cljs @@ -15,10 +15,10 @@ [status-im.ethereum.core :as ethereum] [status-im.native-module.core :as status] [status-im.ens.core :as ens] - [cljs-bean.core :as clj-bean] [status-im.utils.fx :as fx] [taoensso.timbre :as log] - [status-im.ethereum.json-rpc :as json-rpc])) + [status-im.ethereum.json-rpc :as json-rpc] + [status-im.utils.types :as types])) (defn- js-obj->seq [obj] ;; Sometimes the filter will return a single object instead of a collection @@ -42,30 +42,31 @@ (let [chats (.-chats response-js) contacts (.-contacts response-js) installations (.-installations response-js) - raw-messages (.-rawMessages response-js) messages (.-messages response-js)] (cond (seq installations) (let [installation (.pop installations)] (fx/merge cofx - {:dispatch-later [{:ms 20 :dispatch [::process response-js]}]} - (models.pairing/handle-installation (clj-bean/->clj installation)))) + {:utils/dispatch-later [{:ms 20 :dispatch [::process response-js]}]} + (models.pairing/handle-installation (types/js->clj installation)))) (seq contacts) (let [contact (.pop contacts)] (fx/merge cofx - {:dispatch-later [{:ms 20 :dispatch [::process response-js]}]} - (handle-contact (-> contact (clj-bean/->clj) (data-store.contacts/<-rpc))))) + {:utils/dispatch-later [{:ms 20 :dispatch [::process response-js]}]} + (handle-contact (-> contact (types/js->clj) (data-store.contacts/<-rpc))))) + (seq chats) (let [chat (.pop chats)] (fx/merge cofx - {:dispatch-later [{:ms 20 :dispatch [::process response-js]}]} - (handle-chat (-> chat (clj-bean/->clj) (data-store.chats/<-rpc))))) + {:utils/dispatch-later [{:ms 20 :dispatch [::process response-js]}]} + (handle-chat (-> chat (types/js->clj) (data-store.chats/<-rpc))))) + (seq messages) (let [message (.pop messages)] (fx/merge cofx - {:dispatch-later [{:ms 20 :dispatch [::process response-js]}]} - (handle-message (-> message (clj-bean/->clj) (data-store.messages/<-rpc)))))))) + {:utils/dispatch-later [{:ms 20 :dispatch [::process response-js]}]} + (handle-message (-> message (types/js->clj) (data-store.messages/<-rpc)))))))) (handlers/register-handler-fx ::process diff --git a/src/status_im/ui/components/large_toolbar/view.cljs b/src/status_im/ui/components/large_toolbar/view.cljs index f2ae58cfdc..39a5129bee 100644 --- a/src/status_im/ui/components/large_toolbar/view.cljs +++ b/src/status_im/ui/components/large_toolbar/view.cljs @@ -1,11 +1,9 @@ (ns status-im.ui.components.large-toolbar.view (:require [reagent.core :as reagent] - [cljs-bean.core :refer [->clj ->js]] [status-im.ui.components.list.views :as list.views] [status-im.ui.components.react :as react] [status-im.ui.components.toolbar.view :as toolbar] [status-im.ui.components.large-toolbar.styles :as styles] - [status-im.utils.platform :as platform] [status-im.ui.components.animation :as animation]) (:require-macros [status-im.utils.views :as views])) diff --git a/src/status_im/utils/types.cljs b/src/status_im/utils/types.cljs index c90eb6def0..4e11d83663 100644 --- a/src/status_im/utils/types.cljs +++ b/src/status_im/utils/types.cljs @@ -1,19 +1,22 @@ (ns status-im.utils.types - (:require - [cljs-bean.core :as clj-bean])) + (:refer-clojure :exclude [js->clj]) + (:require [cljs-bean.core :as clj-bean])) (defn to-string [s] (if (keyword? s) (name s) s)) +(defn js->clj [data] + (cljs.core/js->clj data :keywordize-keys true)) + (defn clj->json [data] (.stringify js/JSON (clj-bean/->js data))) (defn json->clj [json] (when-not (= json "undefined") (try - (js->clj (.parse js/JSON json) :keywordize-keys true) + (js->clj (.parse js/JSON json)) (catch js/Error _ (when (string? json) json))))) (def serialize clj->json)