mirror of
https://github.com/status-im/status-react.git
synced 2025-01-12 20:14:40 +00:00
fix #812
This commit is contained in:
parent
c1abe16f89
commit
42c356f604
@ -163,20 +163,3 @@
|
||||
(reg-handler ::clear-commands-callbacks
|
||||
(fn [db [chat-id]]
|
||||
(assoc-in db [::commands-callbacks chat-id] nil)))
|
||||
|
||||
(reg-handler :load-default-contacts!
|
||||
(u/side-effect!
|
||||
(fn [{:keys [chats]}]
|
||||
(doseq [[id {:keys [name photo-path public-key add-chat?
|
||||
dapp? dapp-url dapp-hash]}] js-res/default-contacts]
|
||||
(let [id' (clojure.core/name id)]
|
||||
(when-not (chats id')
|
||||
(when add-chat?
|
||||
(dispatch [:add-chat id' {:name (:en name)}]))
|
||||
(dispatch [:add-contacts [{:whisper-identity id'
|
||||
:name (:en name)
|
||||
:photo-path photo-path
|
||||
:public-key public-key
|
||||
:dapp? dapp?
|
||||
:dapp-url (:en dapp-url)
|
||||
:dapp-hash dapp-hash}]])))))))
|
||||
|
@ -13,7 +13,8 @@
|
||||
[status-im.utils.random :as random]
|
||||
[status-im.i18n :refer [label]]
|
||||
[taoensso.timbre :as log]
|
||||
[cljs.reader :refer [read-string]]))
|
||||
[cljs.reader :refer [read-string]]
|
||||
[status-im.utils.js-resources :as js-res]))
|
||||
|
||||
(defmethod nav/preload-data! :group-contacts
|
||||
[db [_ _ group]]
|
||||
@ -185,17 +186,37 @@
|
||||
(update :contacts merge new-contacts')
|
||||
(assoc :new-contacts (vals new-contacts')))))
|
||||
|
||||
(register-handler :add-contacts
|
||||
(after save-contacts!)
|
||||
add-new-contacts)
|
||||
|
||||
(defn public-key->address [public-key]
|
||||
(let [length (count public-key)
|
||||
normalized-key (case length
|
||||
132 (subs public-key 4)
|
||||
130 (subs public-key 2)
|
||||
128 public-key)]
|
||||
(subs (.sha3 js/Web3.prototype normalized-key #js {:encoding "hex"}) 26)))
|
||||
128 public-key
|
||||
nil)]
|
||||
(when normalized-key
|
||||
(subs (.sha3 js/Web3.prototype normalized-key #js {:encoding "hex"}) 26))))
|
||||
|
||||
(register-handler :load-default-contacts!
|
||||
(u/side-effect!
|
||||
(fn [{:keys [chats]}]
|
||||
(doseq [[id {:keys [name photo-path public-key add-chat?
|
||||
dapp? dapp-url dapp-hash]}] js-res/default-contacts]
|
||||
(let [id' (clojure.core/name id)]
|
||||
(when-not (chats id')
|
||||
(when add-chat?
|
||||
(dispatch [:add-chat id' {:name (:en name)}]))
|
||||
(dispatch [:add-contacts [{:whisper-identity id'
|
||||
:address (public-key->address id')
|
||||
:name (:en name)
|
||||
:photo-path photo-path
|
||||
:public-key public-key
|
||||
:dapp? dapp?
|
||||
:dapp-url (:en dapp-url)
|
||||
:dapp-hash dapp-hash}]])))))))
|
||||
|
||||
(register-handler :add-contacts
|
||||
(after save-contacts!)
|
||||
add-new-contacts)
|
||||
|
||||
(defn add-new-contact [db [_ {:keys [whisper-identity] :as contact}]]
|
||||
(-> db
|
||||
|
Loading…
x
Reference in New Issue
Block a user