[refactor] rename whisper-id and whisper-identity to public-key
This commit is contained in:
parent
a6da75f8e9
commit
f8f499d9b0
|
@ -250,7 +250,7 @@
|
|||
;; TODO(goranjovic) - update to include tokens in https://github.com/status-im/status-react/issues/3233
|
||||
(defn- transaction-details [contact symbol]
|
||||
(-> contact
|
||||
(select-keys [:name :address :whisper-identity])
|
||||
(select-keys [:name :address :public-key])
|
||||
(assoc :symbol symbol
|
||||
:gas (ethereum/estimate-gas symbol)
|
||||
:from-chat? true)))
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
(let [statuses (map (fn [message-id]
|
||||
{:chat-id chat-id
|
||||
:message-id message-id
|
||||
:whisper-identity sender
|
||||
:public-key sender
|
||||
:status :seen})
|
||||
seen-messages-ids)]
|
||||
{:db (reduce (fn [acc {:keys [message-id] :as status}]
|
||||
|
|
|
@ -95,10 +95,10 @@
|
|||
updated-statuses (map #(assoc % :status :not-sent) pending-statuses)]
|
||||
{:data-store/tx [(user-statuses-store/save-statuses-tx updated-statuses)]
|
||||
:db (reduce
|
||||
(fn [acc {:keys [chat-id message-id status whisper-identity]}]
|
||||
(fn [acc {:keys [chat-id message-id status public-key]}]
|
||||
(assoc-in acc
|
||||
[:chats chat-id :message-status message-id
|
||||
whisper-identity :status]
|
||||
public-key :status]
|
||||
status))
|
||||
db
|
||||
updated-statuses)}))
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
(let [me (:current-public-key db)
|
||||
status {:chat-id chat-id
|
||||
:message-id message-id
|
||||
:whisper-identity me
|
||||
:public-key me
|
||||
:status status}]
|
||||
{:db (assoc-in db
|
||||
[:chats chat-id :message-statuses message-id me]
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
(assoc acc chat-id (if-let [contact (get contacts chat-id)]
|
||||
(-> chat
|
||||
(assoc :name (:name contact))
|
||||
(assoc :random-name (gfycat/generate-gfy (:whisper-identity contact)))
|
||||
(assoc :random-name (gfycat/generate-gfy (:public-key contact)))
|
||||
(update :tags clojure.set/union (:tags contact)))
|
||||
chat))
|
||||
acc))
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
(fx/defn load-contacts
|
||||
[{:keys [db all-contacts]}]
|
||||
(let [contacts-list (map #(vector (:whisper-identity %) %) all-contacts)
|
||||
(let [contacts-list (map #(vector (:public-key %) %) all-contacts)
|
||||
contacts (into {} contacts-list)]
|
||||
{:db (update db :contacts/contacts #(merge contacts %))}))
|
||||
|
||||
|
@ -25,14 +25,13 @@
|
|||
;; it's not in the contact list at all
|
||||
(nil? pending?))))
|
||||
|
||||
(defn build-contact [{{:keys [chats current-public-key]
|
||||
:account/keys [account]
|
||||
:contacts/keys [contacts]} :db} whisper-id]
|
||||
(cond-> (assoc (or (get contacts whisper-id)
|
||||
(utils.contacts/whisper-id->new-contact whisper-id))
|
||||
:address (utils.contacts/public-key->address whisper-id))
|
||||
(defn build-contact [{{:keys [chats]:account/keys [account]
|
||||
:contacts/keys [contacts]} :db} public-key]
|
||||
(cond-> (assoc (or (get contacts public-key)
|
||||
(utils.contacts/public-key->new-contact public-key))
|
||||
:address (utils.contacts/public-key->address public-key))
|
||||
|
||||
(= whisper-id current-public-key) (assoc :name (:name account))))
|
||||
(= public-key (:public-key account)) (assoc :name (:name account))))
|
||||
|
||||
(defn- own-info [db]
|
||||
(let [{:keys [name photo-path address]} (:account/account db)
|
||||
|
@ -42,27 +41,27 @@
|
|||
:address address
|
||||
:fcm-token fcm-token}))
|
||||
|
||||
(fx/defn add-new-contact [{:keys [db]} {:keys [whisper-identity] :as contact}]
|
||||
(fx/defn add-new-contact [{:keys [db]} {:keys [public-key] :as contact}]
|
||||
(let [new-contact (assoc contact
|
||||
:pending? false
|
||||
:hide-contact? false
|
||||
:public-key whisper-identity)]
|
||||
:public-key public-key)]
|
||||
{:db (-> db
|
||||
(update-in [:contacts/contacts whisper-identity]
|
||||
(update-in [:contacts/contacts public-key]
|
||||
merge new-contact)
|
||||
(assoc-in [:contacts/new-identity] ""))
|
||||
:data-store/tx [(contacts-store/save-contact-tx new-contact)]}))
|
||||
|
||||
(fx/defn send-contact-request
|
||||
[{:keys [db] :as cofx} {:keys [whisper-identity pending? dapp?] :as contact}]
|
||||
[{:keys [db] :as cofx} {:keys [public-key pending? dapp?] :as contact}]
|
||||
(when-not dapp?
|
||||
(if pending?
|
||||
(protocol/send (message.contact/map->ContactRequestConfirmed (own-info db)) whisper-identity cofx)
|
||||
(protocol/send (message.contact/map->ContactRequest (own-info db)) whisper-identity cofx))))
|
||||
(protocol/send (message.contact/map->ContactRequestConfirmed (own-info db)) public-key cofx)
|
||||
(protocol/send (message.contact/map->ContactRequest (own-info db)) public-key cofx))))
|
||||
|
||||
(fx/defn add-contact [{:keys [db] :as cofx} whisper-id]
|
||||
(when (not= (get-in db [:account/account :public-key]) whisper-id)
|
||||
(let [contact (build-contact cofx whisper-id)]
|
||||
(fx/defn add-contact [{:keys [db] :as cofx} public-key]
|
||||
(when (not= (get-in db [:account/account :public-key]) public-key)
|
||||
(let [contact (build-contact cofx public-key)]
|
||||
(fx/merge cofx
|
||||
(add-new-contact contact)
|
||||
(send-contact-request contact)))))
|
||||
|
@ -71,17 +70,17 @@
|
|||
"add a tag to the contact"
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [tag (get-in db [:ui/contact :contact/new-tag])
|
||||
whisper-id (get-in db [:current-chat-id])
|
||||
tags (conj (get-in db [:contacts/contacts whisper-id :tags] #{}) tag)]
|
||||
{:db (assoc-in db [:contacts/contacts whisper-id :tags] tags)
|
||||
:data-store/tx [(contacts-store/add-contact-tag-tx whisper-id tag)]}))
|
||||
public-key (get-in db [:current-chat-id])
|
||||
tags (conj (get-in db [:contacts/contacts public-key :tags] #{}) tag)]
|
||||
{:db (assoc-in db [:contacts/contacts public-key :tags] tags)
|
||||
:data-store/tx [(contacts-store/add-contact-tag-tx public-key tag)]}))
|
||||
|
||||
(fx/defn remove-tag
|
||||
"remove a tag from the contact"
|
||||
[{:keys [db] :as cofx} whisper-id tag]
|
||||
(let [tags (disj (get-in db [:contacts/contacts whisper-id :tags] #{}) tag)]
|
||||
{:db (assoc-in db [:contacts/contacts whisper-id :tags] tags)
|
||||
:data-store/tx [(contacts-store/remove-contact-tag-tx whisper-id tag)]}))
|
||||
[{:keys [db] :as cofx} public-key tag]
|
||||
(let [tags (disj (get-in db [:contacts/contacts public-key :tags] #{}) tag)]
|
||||
{:db (assoc-in db [:contacts/contacts public-key :tags] tags)
|
||||
:data-store/tx [(contacts-store/remove-contact-tag-tx public-key tag)]}))
|
||||
|
||||
(defn handle-contact-update
|
||||
[public-key
|
||||
|
@ -104,21 +103,20 @@
|
|||
;; Backward compatibility with <= 0.9.21, as they don't send
|
||||
;; fcm-token & address in contact updates
|
||||
contact-props (cond->
|
||||
{:whisper-identity public-key
|
||||
:public-key public-key
|
||||
:photo-path profile-image
|
||||
:name name
|
||||
:address (or address
|
||||
(:address contact)
|
||||
(utils.contacts/public-key->address public-key))
|
||||
:last-updated timestamp-ms
|
||||
{:public-key public-key
|
||||
:photo-path profile-image
|
||||
:name name
|
||||
:address (or address
|
||||
(:address contact)
|
||||
(utils.contacts/public-key->address public-key))
|
||||
:last-updated timestamp-ms
|
||||
;;NOTE (yenda) in case of concurrent contact request
|
||||
:pending? (get contact :pending? true)}
|
||||
:pending? (get contact :pending? true)}
|
||||
fcm-token (assoc :fcm-token fcm-token))]
|
||||
;;NOTE (yenda) only update if there is changes to the contact
|
||||
(when-not (= contact-props
|
||||
(select-keys contact [:whisper-identity :public-key :address
|
||||
:photo-path :name :fcm-token :pending?]))
|
||||
(select-keys contact [:public-key :address :photo-path
|
||||
:name :fcm-token :pending?]))
|
||||
{:db (update-in db [:contacts/contacts public-key]
|
||||
merge contact-props)
|
||||
:data-store/tx [(contacts-store/save-contact-tx
|
||||
|
@ -129,15 +127,15 @@
|
|||
(def receive-contact-update handle-contact-update)
|
||||
|
||||
(fx/defn add-contact-and-open-chat
|
||||
[cofx whisper-id]
|
||||
[cofx public-key]
|
||||
(fx/merge cofx
|
||||
(add-contact whisper-id)
|
||||
(chat.models/start-chat whisper-id {:navigation-reset? true})))
|
||||
(add-contact public-key)
|
||||
(chat.models/start-chat public-key {:navigation-reset? true})))
|
||||
|
||||
(fx/defn hide-contact
|
||||
[{:keys [db]} whisper-id]
|
||||
(when (get-in db [:contacts/contacts whisper-id])
|
||||
{:db (assoc-in db [:contacts/contacts whisper-id :hide-contact?] true)}))
|
||||
[{:keys [db]} public-key]
|
||||
(when (get-in db [:contacts/contacts public-key])
|
||||
{:db (assoc-in db [:contacts/contacts public-key :hide-contact?] true)}))
|
||||
|
||||
(fx/defn handle-qr-code
|
||||
[{:keys [db] :as cofx} contact-identity]
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
|
||||
;;Contact
|
||||
|
||||
;;we can't validate public key, because for dapps whisper-identity is just string
|
||||
(spec/def :contact/whisper-identity :global/not-empty-string)
|
||||
;;we can't validate public key, because for dapps public-key is just string
|
||||
(spec/def :contact/public-key :global/not-empty-string)
|
||||
(spec/def :contact/name :global/not-empty-string)
|
||||
(spec/def :contact/address (spec/nilable :global/address))
|
||||
(spec/def :contact/public-key (spec/nilable string?))
|
||||
(spec/def :contact/photo-path (spec/nilable string?))
|
||||
(spec/def :contact/status (spec/nilable string?))
|
||||
(spec/def :contact/fcm-token (spec/nilable string?))
|
||||
|
@ -34,9 +33,8 @@
|
|||
(spec/def :contact/tags (spec/coll-of string? :kind set?))
|
||||
|
||||
(spec/def :contact/contact (spec/keys :req-un [:contact/name]
|
||||
:opt-un [:contact/whisper-identity
|
||||
:opt-un [:contact/public-key
|
||||
:contact/address
|
||||
:contact/public-key
|
||||
:contact/photo-path
|
||||
:contact/status
|
||||
:contact/last-updated
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
(defn sort-contacts [contacts]
|
||||
(sort (fn [c1 c2]
|
||||
(let [name1 (or (:name c1) (:address c1) (:whisper-identity c1))
|
||||
name2 (or (:name c2) (:address c2) (:whisper-identity c2))]
|
||||
(let [name1 (or (:name c1) (:address c1) (:public-key c1))
|
||||
name2 (or (:name c2) (:address c2) (:public-key c2))]
|
||||
(compare (clojure.string/lower-case name1)
|
||||
(clojure.string/lower-case name2))))
|
||||
(vals contacts)))
|
||||
|
@ -60,7 +60,7 @@
|
|||
|
||||
(defn filter-group-contacts [group-contacts contacts]
|
||||
(let [group-contacts' (into #{} group-contacts)]
|
||||
(filter #(group-contacts' (:whisper-identity %)) contacts)))
|
||||
(filter #(group-contacts' (:public-key %)) contacts)))
|
||||
|
||||
(reg-sub :get-contact-by-identity
|
||||
:<- [:get-contacts]
|
||||
|
@ -69,7 +69,7 @@
|
|||
(let [identity' (or identity (first contacts))]
|
||||
(or
|
||||
(get all-contacts identity')
|
||||
(utils.contacts/whisper-id->new-contact identity')))))
|
||||
(utils.contacts/public-key->new-contact identity')))))
|
||||
|
||||
(reg-sub :contacts/dapps-by-name
|
||||
:<- [:all-dapps]
|
||||
|
@ -94,7 +94,7 @@
|
|||
|
||||
(defn query-chat-contacts [[{:keys [contacts]} all-contacts] [_ query-fn]]
|
||||
(let [participant-set (into #{} (filter identity) contacts)]
|
||||
(query-fn (comp participant-set :whisper-identity) (vals all-contacts))))
|
||||
(query-fn (comp participant-set :public-key) (vals all-contacts))))
|
||||
|
||||
(reg-sub :query-current-chat-contacts
|
||||
:<- [:get-current-chat]
|
||||
|
@ -110,12 +110,11 @@
|
|||
|
||||
(defn get-all-contacts-in-group-chat [members contacts current-account]
|
||||
(let [current-account-contact (-> current-account
|
||||
(select-keys [:name :photo-path :public-key])
|
||||
(clojure.set/rename-keys {:public-key :whisper-identity}))
|
||||
all-contacts (assoc contacts (:whisper-identity current-account-contact) current-account-contact)]
|
||||
(select-keys [:name :photo-path :public-key]))
|
||||
all-contacts (assoc contacts (:public-key current-account-contact) current-account-contact)]
|
||||
(->> members
|
||||
(map #(or (get all-contacts %)
|
||||
(utils.contacts/whisper-id->new-contact %)))
|
||||
(utils.contacts/public-key->new-contact %)))
|
||||
(remove :dapp?)
|
||||
(sort-by (comp clojure.string/lower-case :name)))))
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
(defn save-contact-tx
|
||||
"Returns tx function for saving contact"
|
||||
[{:keys [whisper-identity] :as contact}]
|
||||
[{:keys [public-key] :as contact}]
|
||||
(fn [realm]
|
||||
(core/create realm
|
||||
:contact
|
||||
|
@ -31,20 +31,20 @@
|
|||
(doseq [contact contacts]
|
||||
((save-contact-tx contact) realm))))
|
||||
|
||||
(defn- get-contact-by-id [whisper-identity realm]
|
||||
(core/single (core/get-by-field realm :contact :whisper-identity whisper-identity)))
|
||||
(defn- get-contact-by-id [public-key realm]
|
||||
(core/single (core/get-by-field realm :contact :public-key public-key)))
|
||||
|
||||
(defn delete-contact-tx
|
||||
"Returns tx function for deleting contact"
|
||||
[whisper-identity]
|
||||
[public-key]
|
||||
(fn [realm]
|
||||
(core/delete realm (get-contact-by-id whisper-identity realm))))
|
||||
(core/delete realm (get-contact-by-id public-key realm))))
|
||||
|
||||
(defn add-contact-tag-tx
|
||||
"Returns tx function for adding chat contacts"
|
||||
[whisper-identity tag]
|
||||
[public-key tag]
|
||||
(fn [realm]
|
||||
(let [contact (get-contact-by-id whisper-identity realm)
|
||||
(let [contact (get-contact-by-id public-key realm)
|
||||
existing-tags (object/get contact "tags")]
|
||||
(aset contact "tags"
|
||||
(clj->js (into #{} (concat tag
|
||||
|
@ -52,9 +52,9 @@
|
|||
|
||||
(defn remove-contact-tag-tx
|
||||
"Returns tx function for removing chat contacts"
|
||||
[whisper-identity tag]
|
||||
[public-key tag]
|
||||
(fn [realm]
|
||||
(let [contact (get-contact-by-id whisper-identity realm)
|
||||
(let [contact (get-contact-by-id public-key realm)
|
||||
existing-tags (object/get contact "tags")]
|
||||
(aset contact "tags"
|
||||
(clj->js (remove (into #{} tag)
|
||||
|
|
|
@ -89,8 +89,8 @@
|
|||
(-> @core/account-realm
|
||||
(core/get-by-fields
|
||||
:user-status
|
||||
:and {:whisper-identity public-key
|
||||
:status "received"})
|
||||
:and {:public-key public-key
|
||||
:status "received"})
|
||||
(core/all-clj :user-status)))))
|
||||
|
||||
(re-frame/reg-cofx
|
||||
|
|
|
@ -52,3 +52,28 @@
|
|||
:debug? {:type :bool
|
||||
:default false}
|
||||
:tags {:type "string[]"}}})
|
||||
|
||||
(def v3 {:name :contact
|
||||
:primaryKey :public-key
|
||||
:properties {:address {:type :string :optional true}
|
||||
:name {:type :string :optional true}
|
||||
:photo-path {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-online {:type :int :default 0}
|
||||
:pending? {:type :bool :default false}
|
||||
:hide-contact? {:type :bool :default false}
|
||||
:status {:type :string :optional true}
|
||||
:fcm-token {:type :string :optional true}
|
||||
:description {:type :string :optional true}
|
||||
:public-key :string
|
||||
:dapp? {:type :bool
|
||||
:default false}
|
||||
:dapp-url {:type :string
|
||||
:optional true}
|
||||
:bot-url {:type :string
|
||||
:optional true}
|
||||
:dapp-hash {:type :int
|
||||
:optional true}
|
||||
:debug? {:type :bool
|
||||
:default false}
|
||||
:tags {:type "string[]"}}})
|
||||
|
|
|
@ -226,6 +226,19 @@
|
|||
browser/v8
|
||||
dapp-permissions/v9])
|
||||
|
||||
(def v23 [chat/v8
|
||||
transport/v7
|
||||
contact/v3
|
||||
message/v7
|
||||
mailserver/v11
|
||||
mailserver-topic/v1
|
||||
user-status/v2
|
||||
membership-update/v1
|
||||
installation/v1
|
||||
local-storage/v1
|
||||
browser/v8
|
||||
dapp-permissions/v9])
|
||||
|
||||
;; put schemas ordered by version
|
||||
(def schemas [{:schema v1
|
||||
:schemaVersion 1
|
||||
|
@ -292,4 +305,7 @@
|
|||
:migration migrations/v21}
|
||||
{:schema v22
|
||||
:schemaVersion 22
|
||||
:migration migrations/v22}])
|
||||
:migration migrations/v22}
|
||||
{:schema v23
|
||||
:schemaVersion 23
|
||||
:migration migrations/v23}])
|
||||
|
|
|
@ -133,3 +133,23 @@
|
|||
|
||||
(defn v22 [old-realm new-realm]
|
||||
(log/debug "migrating v22 account database"))
|
||||
|
||||
(defn v23
|
||||
"the primary key for contact was whisper-identity
|
||||
change to public-key and remove whisper-identity field"
|
||||
[old-realm new-realm]
|
||||
(log/debug "migrating v20 account database")
|
||||
(let [old-contacts (.objects old-realm "contact")
|
||||
new-contacts (.objects new-realm "contact")]
|
||||
(dotimes [i (.-length old-contacts)]
|
||||
(let [old-contact (aget old-contacts i)
|
||||
new-contact (aget new-contacts i)
|
||||
whisper-identity (aget old-contact "whisper-identity")]
|
||||
(aset new-contact "public-key" whisper-identity))))
|
||||
(let [old-user-statuses (.objects old-realm "user-status")
|
||||
new-user-statuses (.objects new-realm "user-status")]
|
||||
(dotimes [i (.-length old-user-statuses)]
|
||||
(let [old-user-status (aget old-user-statuses i)
|
||||
new-user-status (aget new-user-statuses i)
|
||||
whisper-identity (aget old-user-status "whisper-identity")]
|
||||
(aset new-user-status "public-key" whisper-identity)))))
|
||||
|
|
|
@ -10,3 +10,14 @@
|
|||
:chat-id :string
|
||||
:whisper-identity :string
|
||||
:status :string}})
|
||||
|
||||
(def v2 {:name :user-status
|
||||
:primaryKey :status-id
|
||||
:properties {;; Unfortunately, realm doesn't support composite primary keys,
|
||||
;; so we have to keep separate `:status-id` property, which is just
|
||||
;; `:message-id`-`:public-key` concatenated
|
||||
:status-id :string
|
||||
:message-id :string
|
||||
:chat-id :string
|
||||
:public-key :string
|
||||
:status :string}})
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
[status-im.data-store.realm.core :as core]))
|
||||
|
||||
(defn- prepare-statuses [statuses]
|
||||
(reduce (fn [acc {:keys [message-id whisper-identity] :as user-status}]
|
||||
(reduce (fn [acc {:keys [message-id public-key] :as user-status}]
|
||||
(assoc-in acc
|
||||
[message-id whisper-identity]
|
||||
[message-id public-key]
|
||||
(-> user-status
|
||||
(update :status keyword)
|
||||
(dissoc :status-id))))
|
||||
|
@ -28,8 +28,8 @@
|
|||
(fn [cofx _]
|
||||
(assoc cofx :get-stored-user-statuses get-by-chat-and-messages-ids)))
|
||||
|
||||
(defn- compute-status-id [{:keys [message-id whisper-identity]}]
|
||||
(str message-id "-" whisper-identity))
|
||||
(defn- compute-status-id [{:keys [message-id public-key]}]
|
||||
(str message-id "-" public-key))
|
||||
|
||||
(defn save-status-tx
|
||||
"Returns tx function for saving message user status"
|
||||
|
|
|
@ -1053,13 +1053,13 @@
|
|||
(handlers/register-handler-fx
|
||||
:contact.ui/add-to-contact-pressed
|
||||
[(re-frame/inject-cofx :random-id-generator)]
|
||||
(fn [cofx [_ whisper-id]]
|
||||
(contact/add-contact cofx whisper-id)))
|
||||
(fn [cofx [_ public-key]]
|
||||
(contact/add-contact cofx public-key)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:contact.ui/close-contact-pressed
|
||||
(fn [cofx [_ whisper-id]]
|
||||
(contact/hide-contact cofx whisper-id)))
|
||||
(fn [cofx [_ public-key]]
|
||||
(contact/hide-contact cofx public-key)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:contact/qr-code-scanned
|
||||
|
@ -1075,8 +1075,8 @@
|
|||
(handlers/register-handler-fx
|
||||
:contact.ui/send-message-pressed
|
||||
[(re-frame/inject-cofx :random-id-generator)]
|
||||
(fn [cofx [_ {:keys [whisper-identity]}]]
|
||||
(contact/add-contact-and-open-chat cofx whisper-identity)))
|
||||
(fn [cofx [_ {:keys [public-key]}]]
|
||||
(contact/add-contact-and-open-chat cofx public-key)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:contact.ui/contact-code-submitted
|
||||
|
|
|
@ -308,7 +308,7 @@
|
|||
{:chat-id chat-id
|
||||
:content {:text text}
|
||||
:clock-value clock-value
|
||||
:from (:whisper-identity contact)})
|
||||
:from (:public-key contact)})
|
||||
creator-contact (when creator (get-contact creator))
|
||||
name-changed-author (when name-changed? (get-contact (:name-changed-by clock-values)))
|
||||
contacts-added (map
|
||||
|
@ -331,12 +331,12 @@
|
|||
(seq members-added) (concat (map #(format-message
|
||||
%
|
||||
(i18n/label :t/group-chat-member-added {:member (:name %)})
|
||||
(get-in clock-values [(:whisper-identity %) :added]))
|
||||
(get-in clock-values [(:public-key %) :added]))
|
||||
contacts-added))
|
||||
(seq members-removed) (concat (map #(format-message
|
||||
%
|
||||
(i18n/label :t/group-chat-member-removed {:member (:name %)})
|
||||
(get-in clock-values [(:whisper-identity %) :removed]))
|
||||
(get-in clock-values [(:public-key %) :removed]))
|
||||
contacts-removed)))))
|
||||
|
||||
(fx/defn add-system-messages [cofx chat-id previous-chat clock-values]
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
(assoc :photo-path
|
||||
(or (:photo-path new-contact)
|
||||
(:photo-path old-contact)
|
||||
(identicon/identicon (:whisper-identity local))))
|
||||
(identicon/identicon (:public-key local))))
|
||||
(assoc :pending? (boolean
|
||||
(and (:pending? local true)
|
||||
(:pending? remote true)))))))
|
||||
|
|
|
@ -58,12 +58,8 @@
|
|||
(defrecord ContactUpdate [name profile-image address fcm-token]
|
||||
protocol/StatusMessage
|
||||
(send [this _ {:keys [db] :as cofx}]
|
||||
;;TODO: here we look for contact which have a :public-key to differentiate
|
||||
;;actual contacts from dapps
|
||||
;;This is not an ideal solution and we should think about a more reliable way
|
||||
;;to do this when we refactor app-db
|
||||
(let [contact-public-keys (reduce (fn [acc [_ {:keys [public-key pending?]}]]
|
||||
(if (and public-key
|
||||
(let [contact-public-keys (reduce (fn [acc [_ {:keys [public-key dapp? pending?]}]]
|
||||
(if (and (not dapp?)
|
||||
(not pending?))
|
||||
(conj acc public-key)
|
||||
acc))
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
[status-im.ui.components.contact.styles :as styles]
|
||||
[status-im.ui.components.list-selection :as list-selection]
|
||||
[status-im.ui.components.list.views :as list]
|
||||
[status-im.utils.gfycat.core :as gfycat]))
|
||||
[status-im.utils.gfycat.core :as gfycat]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(defn desktop-extended-options [options]
|
||||
[react/view {}
|
||||
|
@ -20,7 +21,7 @@
|
|||
[react/text {} label]]]))])
|
||||
|
||||
(defn- contact-inner-view
|
||||
([{:keys [info style props] {:keys [whisper-identity name dapp?] :as contact} :contact}]
|
||||
([{:keys [info style props] {:keys [public-key name dapp?] :as contact} :contact}]
|
||||
[react/view (merge styles/contact-inner-container style)
|
||||
[react/view
|
||||
[chat-icon/contact-icon-contacts-tab contact]]
|
||||
|
@ -30,7 +31,7 @@
|
|||
(when dapp? {:accessibility-label :dapp-name})
|
||||
props)
|
||||
(if (string/blank? name)
|
||||
(gfycat/generate-gfy whisper-identity)
|
||||
(gfycat/generate-gfy public-key)
|
||||
(or name (i18n/label :t/chat-name)))]
|
||||
(when info
|
||||
[react/text {:style styles/info-text}
|
||||
|
@ -57,12 +58,12 @@
|
|||
[react/view styles/more-btn
|
||||
[vector-icons/icon :icons/options {:accessibility-label :options}]]]]))]])
|
||||
|
||||
(views/defview toogle-contact-view [{:keys [whisper-identity] :as contact} selected-key on-toggle-handler]
|
||||
(views/letsubs [checked [selected-key whisper-identity]]
|
||||
(views/defview toogle-contact-view [{:keys [public-key] :as contact} selected-key on-toggle-handler]
|
||||
(views/letsubs [checked [selected-key public-key]]
|
||||
[react/view {:accessibility-label :contact-item}
|
||||
[list/list-item-with-checkbox
|
||||
{:checked? checked
|
||||
:on-value-change #(on-toggle-handler checked whisper-identity)
|
||||
:on-value-change #(on-toggle-handler checked public-key)
|
||||
:plain-checkbox? true}
|
||||
[react/view styles/contact-container
|
||||
[contact-inner-view {:contact contact}]]]]))
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
[cljs.spec.alpha :as spec]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(defn own-whisper-identity?
|
||||
[{{:keys [public-key]} :account/account} whisper-identity]
|
||||
(= whisper-identity public-key))
|
||||
(defn own-public-key?
|
||||
[{:account/keys [account]} public-key]
|
||||
(= (:public-key account) public-key))
|
||||
|
||||
(defn validate-pub-key [db whisper-identity]
|
||||
(defn validate-pub-key [db public-key]
|
||||
(cond
|
||||
(not (spec/valid? :global/public-key whisper-identity))
|
||||
(not (spec/valid? :global/public-key public-key))
|
||||
(i18n/label (if platform/desktop?
|
||||
:t/use-valid-contact-code-desktop
|
||||
:t/use-valid-contact-code))
|
||||
(own-whisper-identity? db whisper-identity)
|
||||
(own-public-key? db public-key)
|
||||
(i18n/label :t/can-not-add-yourself)))
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
[clojure.string :as string]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:resolve-whisper-identity
|
||||
:resolve-public-key
|
||||
(fn [{:keys [web3 registry ens-name cb]}]
|
||||
(resolver/pubkey web3 registry ens-name cb)))
|
||||
|
||||
|
@ -23,9 +23,9 @@
|
|||
(when-not is-public-key?
|
||||
(let [network (get-in db [:account/account :networks network])
|
||||
chain (ethereum/network->chain-keyword network)]
|
||||
{:resolve-whisper-identity {:web3 web3
|
||||
:registry (get ens/ens-registries chain)
|
||||
:ens-name (if (ens/is-valid-eth-name? new-identity)
|
||||
new-identity
|
||||
(str new-identity ".stateofus.eth"))
|
||||
:cb #(re-frame/dispatch [:new-chat/set-new-identity %])}}))))))
|
||||
{:resolve-public-key {:web3 web3
|
||||
:registry (get ens/ens-registries chain)
|
||||
:ens-name (if (ens/is-valid-eth-name? new-identity)
|
||||
new-identity
|
||||
(str new-identity ".stateofus.eth"))
|
||||
:cb #(re-frame/dispatch [:new-chat/set-new-identity %])}}))))))
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
(defn- render-row [row _ _]
|
||||
[contact-view/contact-view {:contact row
|
||||
:on-press #(re-frame/dispatch [:chat.ui/start-chat (:whisper-identity %) {:navigation-reset? true}])
|
||||
:on-press #(re-frame/dispatch [:chat.ui/start-chat (:public-key %) {:navigation-reset? true}])
|
||||
:show-forward? true}])
|
||||
|
||||
(views/defview new-chat []
|
||||
|
|
|
@ -40,24 +40,24 @@
|
|||
[react/animated-view {:style (styles/bottom-info-container height)}
|
||||
(into [react/view] children)])})))
|
||||
|
||||
(defn- message-status-row [{:keys [photo-path name]} {:keys [whisper-identity status]}]
|
||||
(defn- message-status-row [{:keys [photo-path name]} {:keys [public-key status]}]
|
||||
[react/view styles/bottom-info-row
|
||||
[photos/photo
|
||||
(or photo-path (identicon/identicon whisper-identity))
|
||||
(or photo-path (identicon/identicon public-key))
|
||||
styles/bottom-info-row-photo-size]
|
||||
[react/view styles/bottom-info-row-text-container
|
||||
[react/text {:style styles/bottom-info-row-text1
|
||||
:number-of-lines 1}
|
||||
(utils/truncate-str (if-not (string/blank? name)
|
||||
name
|
||||
whisper-identity) 30)]
|
||||
public-key) 30)]
|
||||
[react/text {:style styles/bottom-info-row-text2
|
||||
:number-of-lines 1}
|
||||
(i18n/message-status-label (or status :sending))]]])
|
||||
|
||||
(defn- render-status [contacts]
|
||||
(fn [{:keys [whisper-identity] :as row} _ _]
|
||||
(let [contact (get contacts whisper-identity)]
|
||||
(fn [{:keys [public-key] :as row} _ _]
|
||||
(let [contact (get contacts public-key)]
|
||||
[message-status-row contact row])))
|
||||
|
||||
(defn bottom-info-view []
|
||||
|
@ -70,8 +70,8 @@
|
|||
(let [{:keys [user-statuses message-status participants]} @bottom-info
|
||||
participants (->> participants
|
||||
(map (fn [{:keys [identity]}]
|
||||
[identity {:whisper-identity identity
|
||||
:status message-status}]))
|
||||
[identity {:public-key identity
|
||||
:status message-status}]))
|
||||
(into {}))
|
||||
statuses (vals (merge participants user-statuses))]
|
||||
[overlay {:on-click-outside #(re-frame/dispatch [:chat.ui/set-chat-ui-props {:show-bottom-info? false}])}
|
||||
|
|
|
@ -146,10 +146,10 @@
|
|||
:user-statuses delivery-statuses
|
||||
:participants participants}])}
|
||||
[react/view style/delivery-view
|
||||
(for [[whisper-identity] (take 3 delivery-statuses)]
|
||||
^{:key whisper-identity}
|
||||
[react/image {:source {:uri (or (get-in contacts [whisper-identity :photo-path])
|
||||
(identicon/identicon whisper-identity))}
|
||||
(for [[public-key] (take 3 delivery-statuses)]
|
||||
^{:key public-key}
|
||||
[react/image {:source {:uri (or (get-in contacts [public-key :photo-path])
|
||||
(identicon/identicon public-key))}
|
||||
:style {:width 16
|
||||
:height 16
|
||||
:border-radius 8}}])
|
||||
|
|
|
@ -84,10 +84,10 @@
|
|||
[react/view {:style styles/suggested-contacts}
|
||||
(doall
|
||||
(for [c contacts]
|
||||
^{:key (:whisper-identity c)}
|
||||
^{:key (:public-key c)}
|
||||
[react/touchable-highlight {:on-press #(do
|
||||
(re-frame/dispatch [:set :contacts/new-identity (:whisper-identity c)])
|
||||
(re-frame/dispatch [:contact.ui/contact-code-submitted (:whisper-identity c)]))}
|
||||
(re-frame/dispatch [:set :contacts/new-identity (:public-key c)])
|
||||
(re-frame/dispatch [:contact.ui/contact-code-submitted (:public-key c)]))}
|
||||
[react/view {:style styles/suggested-contact-view}
|
||||
[react/image {:style styles/suggested-contact-image
|
||||
:source {:uri (:photo-path c)}}]
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
(views/defview toolbar-chat-view [{:keys [chat-id color public-key public? group-chat]
|
||||
:as current-chat}]
|
||||
(views/letsubs [chat-name [:get-current-chat-name]
|
||||
{:keys [pending? whisper-identity photo-path]} [:get-current-chat-contact]]
|
||||
{:keys [pending? public-key photo-path]} [:get-current-chat-contact]]
|
||||
[react/view {:style styles/toolbar-chat-view}
|
||||
[react/view {:style {:flex-direction :row
|
||||
:flex 1}}
|
||||
|
@ -44,7 +44,7 @@
|
|||
chat-name]
|
||||
(cond pending?
|
||||
[react/text {:style styles/add-contact-text
|
||||
:on-press #(re-frame/dispatch [:contact.ui/add-to-contact-pressed whisper-identity])}
|
||||
:on-press #(re-frame/dispatch [:contact.ui/add-to-contact-pressed public-key])}
|
||||
(i18n/label :t/add-to-contacts)]
|
||||
public?
|
||||
[react/text {:style styles/public-chat-text}
|
||||
|
@ -52,7 +52,7 @@
|
|||
[react/view
|
||||
(when (and (not group-chat) (not public?))
|
||||
[react/text {:style (styles/profile-actions-text colors/black)
|
||||
:on-press #(re-frame/dispatch [:show-profile-desktop whisper-identity])}
|
||||
:on-press #(re-frame/dispatch [:show-profile-desktop public-key])}
|
||||
(i18n/label :t/view-profile)])
|
||||
(when (and group-chat (not public?))
|
||||
[react/text {:style (styles/profile-actions-text colors/black)
|
||||
|
@ -332,14 +332,14 @@
|
|||
(views/defview chat-profile []
|
||||
(views/letsubs [identity [:get-current-contact-identity]
|
||||
maybe-contact [:get-current-contact]]
|
||||
(let [contact (or maybe-contact (utils.contacts/whisper-id->new-contact identity))
|
||||
{:keys [pending? whisper-identity]} contact]
|
||||
(let [contact (or maybe-contact (utils.contacts/public-key->new-contact identity))
|
||||
{:keys [pending? public-key]} contact]
|
||||
[react/view {:style styles/chat-profile-body}
|
||||
[profile.views/profile-badge contact]
|
||||
;; for private chat, public key will be chat-id
|
||||
[react/view
|
||||
(if (or (nil? pending?) pending?)
|
||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:contact.ui/add-to-contact-pressed whisper-identity])}
|
||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:contact.ui/add-to-contact-pressed public-key])}
|
||||
[react/view {:style styles/chat-profile-row}
|
||||
[react/view {:style styles/chat-profile-icon-container
|
||||
:accessibility-label :add-contact-link}
|
||||
|
@ -352,7 +352,7 @@
|
|||
[react/text {:style (styles/contact-card-text colors/gray)} (i18n/label :t/in-contacts)]])
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch
|
||||
[:contact.ui/send-message-pressed {:whisper-identity whisper-identity}])}
|
||||
[:contact.ui/send-message-pressed {:public-key public-key}])}
|
||||
[react/view {:style styles/chat-profile-row}
|
||||
[react/view {:style styles/chat-profile-icon-container
|
||||
:accessibility-label :send-message-link}
|
||||
|
@ -362,4 +362,4 @@
|
|||
[react/text {:style styles/chat-profile-contact-code} (i18n/label :t/contact-code)]
|
||||
[react/text {:style {:font-size 14}
|
||||
:selectable true
|
||||
:selection-color colors/blue} whisper-identity]]])))
|
||||
:selection-color colors/blue} public-key]]])))
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
[status-im.ui.screens.group.styles :as styles]))
|
||||
|
||||
(defn- on-toggle [checked? whisper-identity]
|
||||
(defn- on-toggle [checked? public-key]
|
||||
(let [action (if checked? :deselect-contact :select-contact)]
|
||||
(re-frame/dispatch [action whisper-identity])))
|
||||
(re-frame/dispatch [action public-key])))
|
||||
|
||||
(defn- on-toggle-participant [checked? whisper-identity]
|
||||
(defn- on-toggle-participant [checked? public-key]
|
||||
(let [action (if checked? :deselect-participant :select-participant)]
|
||||
(re-frame/dispatch [action whisper-identity])))
|
||||
(re-frame/dispatch [action public-key])))
|
||||
|
||||
(defn- group-toggle-contact [contact]
|
||||
[toogle-contact-view contact :is-contact-selected? on-toggle])
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
(count selected-participants)))
|
||||
|
||||
(defn filter-contacts [selected-contacts added-contacts]
|
||||
(filter #(selected-contacts (:whisper-identity %)) added-contacts))
|
||||
(filter #(selected-contacts (:public-key %)) added-contacts))
|
||||
|
||||
(reg-sub
|
||||
:selected-group-contacts
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
toolbar/default-nav-back
|
||||
[toolbar/content-title ""]])
|
||||
|
||||
(defn actions [{:keys [pending? whisper-identity dapp?]}]
|
||||
(defn actions [{:keys [pending? public-key dapp?]}]
|
||||
(concat (if (or (nil? pending?) pending?)
|
||||
[{:label (i18n/label :t/add-to-contacts)
|
||||
:icon :icons/add-contact
|
||||
:action #(re-frame/dispatch [:contact.ui/add-to-contact-pressed whisper-identity])
|
||||
:action #(re-frame/dispatch [:contact.ui/add-to-contact-pressed public-key])
|
||||
:accessibility-label :add-to-contacts-button}]
|
||||
[{:label (i18n/label :t/in-contacts)
|
||||
:icon :icons/in-contacts
|
||||
|
@ -28,16 +28,16 @@
|
|||
:accessibility-label :in-contacts-button}])
|
||||
[{:label (i18n/label :t/send-message)
|
||||
:icon :icons/chats
|
||||
:action #(re-frame/dispatch [:contact.ui/send-message-pressed {:whisper-identity whisper-identity}])
|
||||
:action #(re-frame/dispatch [:contact.ui/send-message-pressed {:public-key public-key}])
|
||||
:accessibility-label :start-conversation-button}]
|
||||
(when-not dapp?
|
||||
[{:label (i18n/label :t/send-transaction)
|
||||
:icon :icons/arrow-right
|
||||
:action #(re-frame/dispatch [:profile/send-transaction whisper-identity])
|
||||
:action #(re-frame/dispatch [:profile/send-transaction public-key])
|
||||
:accessibility-label :send-transaction-button}])
|
||||
[{:label (i18n/label :t/share-profile-link)
|
||||
:icon :icons/share
|
||||
:action #(re-frame/dispatch [:profile/share-profile-link whisper-identity])
|
||||
:action #(re-frame/dispatch [:profile/share-profile-link public-key])
|
||||
:accessibility-label :share-profile-link}]))
|
||||
|
||||
(defn profile-info-item [{:keys [label value options accessibility-label]}]
|
||||
|
@ -51,20 +51,20 @@
|
|||
:selectable true}
|
||||
value]]])
|
||||
|
||||
(defn profile-info-contact-code-item [whisper-identity]
|
||||
(defn profile-info-contact-code-item [public-key]
|
||||
[profile-info-item
|
||||
{:label (i18n/label :t/contact-code)
|
||||
:accessibility-label :profile-public-key
|
||||
:value whisper-identity}])
|
||||
:value public-key}])
|
||||
|
||||
(defn profile-info [{:keys [whisper-identity]}]
|
||||
(defn profile-info [{:keys [public-key]}]
|
||||
[react/view
|
||||
[profile-info-contact-code-item whisper-identity]])
|
||||
[profile-info-contact-code-item public-key]])
|
||||
|
||||
(defview profile []
|
||||
(letsubs [identity [:get-current-contact-identity]
|
||||
maybe-contact [:get-current-contact]]
|
||||
(let [contact (or maybe-contact (utils.contacts/whisper-id->new-contact identity))]
|
||||
(let [contact (or maybe-contact (utils.contacts/public-key->new-contact identity))]
|
||||
[react/view profile.components.styles/profile
|
||||
[status-bar/status-bar]
|
||||
[profile-contact-toolbar]
|
||||
|
|
|
@ -53,23 +53,23 @@
|
|||
:accessibility-label :delete-chat-button}]))
|
||||
|
||||
(defn member-actions [chat-id member]
|
||||
[{:action #(re-frame/dispatch [(if platform/desktop? :show-profile-desktop :chat.ui/show-profile) (:whisper-identity member)])
|
||||
[{:action #(re-frame/dispatch [(if platform/desktop? :show-profile-desktop :chat.ui/show-profile) (:public-key member)])
|
||||
:label (i18n/label :t/view-profile)}
|
||||
{:action #(re-frame/dispatch [:group-chats.ui/remove-member-pressed chat-id (:whisper-identity member)])
|
||||
{:action #(re-frame/dispatch [:group-chats.ui/remove-member-pressed chat-id (:public-key member)])
|
||||
:label (i18n/label :t/remove-from-chat)}])
|
||||
|
||||
(defn render-member [chat-id {:keys [name whisper-identity] :as member} admin? current-user-identity]
|
||||
(defn render-member [chat-id {:keys [name public-key] :as member} admin? current-user-identity]
|
||||
[react/view
|
||||
[contact/contact-view
|
||||
{:contact member
|
||||
:extend-options (member-actions chat-id member)
|
||||
:extend-title name
|
||||
:extended? (and admin?
|
||||
(not= whisper-identity current-user-identity))
|
||||
(not= public-key current-user-identity))
|
||||
:accessibility-label :member-item
|
||||
:inner-props {:accessibility-label :member-name-text}
|
||||
:on-press (when (not= whisper-identity current-user-identity)
|
||||
#(re-frame/dispatch [(if platform/desktop? :show-profile-desktop :chat.ui/show-profile) whisper-identity]))}]])
|
||||
:on-press (when (not= public-key current-user-identity)
|
||||
#(re-frame/dispatch [(if platform/desktop? :show-profile-desktop :chat.ui/show-profile) public-key]))}]])
|
||||
|
||||
(defview chat-group-members-view [chat-id admin? current-user-identity]
|
||||
(letsubs [members [:get-current-chat-contacts]]
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
(defn- find-address-name [db address]
|
||||
(:name (utils.contacts/find-contact-by-address (:contacts/contacts db) address)))
|
||||
|
||||
(defn- fill-request-details [db {:keys [address name value symbol gas gasPrice whisper-identity from-chat?]}]
|
||||
(defn- fill-request-details [db {:keys [address name value symbol gas gasPrice public-key from-chat?]}]
|
||||
{:pre [(not (nil? address))]}
|
||||
(let [name (or name (find-address-name db address))]
|
||||
(update-in
|
||||
db [:wallet :send-transaction]
|
||||
(fn [{old-symbol :symbol :as old-transaction}]
|
||||
(let [symbol-changed? (not= old-symbol symbol)]
|
||||
(cond-> (assoc old-transaction :to address :to-name name :whisper-identity whisper-identity)
|
||||
(cond-> (assoc old-transaction :to address :to-name name :public-key public-key)
|
||||
value (assoc :amount value)
|
||||
symbol (assoc :symbol symbol)
|
||||
(and gas symbol-changed?) (assoc :gas (money/bignumber gas))
|
||||
|
@ -103,17 +103,17 @@
|
|||
(and address valid-network?) (update :db #(fill-request-details % details))
|
||||
symbol-changed? (changed-asset old-symbol new-symbol)
|
||||
(and old-amount new-amount (not= old-amount new-amount)) (changed-amount-warning old-amount new-amount)
|
||||
;; NOTE(goranjovic) - the next line is there is because QR code scanning switches the amount to ETH
|
||||
;; automatically, so we need to update the gas limit accordingly. The check for origin screen is there
|
||||
;; so that we wouldn't also switch gas limit to ETH specific if the user pastes address as text.
|
||||
;; We need to check if address is defined so that we wouldn't trigger this behavior when invalid QR is scanned
|
||||
;; (e.g. whisper-id)
|
||||
;; NOTE(goranjovic) - the next line is there is because QR code scanning switches the amount to ETH
|
||||
;; automatically, so we need to update the gas limit accordingly. The check for origin screen is there
|
||||
;; so that we wouldn't also switch gas limit to ETH specific if the user pastes address as text.
|
||||
;; We need to check if address is defined so that we wouldn't trigger this behavior when invalid QR is scanned
|
||||
;; (e.g. public-key)
|
||||
(and address (= origin :qr) (not new-gas) symbol-changed?) (use-default-eth-gas)
|
||||
(not address) (assoc :ui/show-error (i18n/label :t/wallet-invalid-address {:data data}))
|
||||
(and address (not valid-network?)) (assoc :ui/show-error (i18n/label :t/wallet-invalid-chain-id {:data data :chain current-chain-id}))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/fill-request-from-contact
|
||||
(fn [{db :db} [_ {:keys [address name whisper-identity]}]]
|
||||
{:db (fill-request-details db {:address address :name name :whisper-identity whisper-identity})
|
||||
(fn [{db :db} [_ {:keys [address name public-key]}]]
|
||||
{:db (fill-request-details db {:address address :name name :public-key public-key})
|
||||
:dispatch [:navigate-back]}))
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
(handlers/register-handler-fx
|
||||
:wallet-send-request
|
||||
(fn [{:keys [db] :as cofx} [_ whisper-identity amount symbol decimals]]
|
||||
(assert whisper-identity)
|
||||
(fn [{:keys [db] :as cofx} [_ public-key amount symbol decimals]]
|
||||
(assert public-key)
|
||||
(let [request-command (get-in db [:id->command ["request" #{:personal-chats}]])]
|
||||
(fx/merge cofx
|
||||
(chat-model/start-chat whisper-identity nil)
|
||||
(commands-sending/send whisper-identity
|
||||
(chat-model/start-chat public-key nil)
|
||||
(commands-sending/send public-key
|
||||
request-command
|
||||
{:asset (name symbol)
|
||||
:amount (str (money/internal->formatted amount symbol decimals))})))))
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
(views/defview send-transaction-request []
|
||||
;; TODO(jeluard) both send and request flows should be merged
|
||||
(views/letsubs [network [:get-current-account-network]
|
||||
{:keys [to to-name whisper-identity]} [:wallet.send/transaction]
|
||||
{:keys [to to-name public-key]} [:wallet.send/transaction]
|
||||
{:keys [amount amount-error amount-text symbol]} [:wallet.request/transaction]
|
||||
network-status [:network-status]
|
||||
scroll (atom nil)]
|
||||
|
@ -57,7 +57,7 @@
|
|||
[bottom-buttons/bottom-buttons styles/bottom-buttons
|
||||
nil ;; Force a phantom button to ensure consistency with other transaction screens which define 2 buttons
|
||||
[button/button {:disabled? (or amount-error (not (and to amount)))
|
||||
:on-press #(re-frame/dispatch [:wallet-send-request whisper-identity amount
|
||||
:on-press #(re-frame/dispatch [:wallet-send-request public-key amount
|
||||
(wallet.utils/display-symbol token) decimals])
|
||||
:text-style {:padding-horizontal 0}
|
||||
:accessibility-label :sent-request-button}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
(spec/def ::from-chat? (spec/nilable boolean?))
|
||||
(spec/def ::symbol (spec/nilable keyword?))
|
||||
(spec/def ::advanced? boolean?)
|
||||
(spec/def ::whisper-identity (spec/nilable string?))
|
||||
(spec/def ::public-key (spec/nilable string?))
|
||||
(spec/def ::method (spec/nilable string?))
|
||||
(spec/def ::tx-hash (spec/nilable string?))
|
||||
(spec/def ::on-result (spec/nilable any?))
|
||||
|
@ -38,4 +38,4 @@
|
|||
::password ::show-password-input? ::id ::from ::data ::nonce
|
||||
::camera-flashlight ::in-progress? ::on-result ::on-error
|
||||
::wrong-password? ::from-chat? ::symbol ::advanced?
|
||||
::gas ::gas-price ::whisper-identity ::method ::tx-hash]))
|
||||
::gas ::gas-price ::public-key ::method ::tx-hash]))
|
||||
|
|
|
@ -83,12 +83,12 @@
|
|||
(handlers/register-handler-fx
|
||||
::transaction-completed
|
||||
(fn [{:keys [db now] :as cofx} [_ {:keys [result error]}]]
|
||||
(let [{:keys [id method whisper-identity to symbol amount-text on-result]} (get-in db [:wallet :send-transaction])
|
||||
(let [{:keys [id method public-key to symbol amount-text on-result]} (get-in db [:wallet :send-transaction])
|
||||
db' (assoc-in db [:wallet :send-transaction :in-progress?] false)]
|
||||
(if error
|
||||
;; ERROR
|
||||
;; ERROR
|
||||
(models.wallet/handle-transaction-error (assoc cofx :db db') error)
|
||||
;; RESULT
|
||||
;; RESULT
|
||||
(merge
|
||||
{:db (cond-> (assoc-in db' [:wallet :send-transaction] {})
|
||||
|
||||
|
@ -98,10 +98,10 @@
|
|||
|
||||
(if on-result
|
||||
{:dispatch (conj on-result id result method)}
|
||||
{:dispatch [:send-transaction-message whisper-identity {:address to
|
||||
:asset (name symbol)
|
||||
:amount amount-text
|
||||
:tx-hash result}]}))))))
|
||||
{:dispatch [:send-transaction-message public-key {:address to
|
||||
:asset (name symbol)
|
||||
:amount amount-text
|
||||
:tx-hash result}]}))))))
|
||||
|
||||
;; DISCARD TRANSACTION
|
||||
(handlers/register-handler-fx
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
[status-im.utils.gfycat.core :as gfycat]
|
||||
[status-im.utils.ethereum.core :as ethereum]))
|
||||
|
||||
(defn whisper-id->new-contact [whisper-id]
|
||||
{:name (gfycat/generate-gfy whisper-id)
|
||||
:photo-path (identicon/identicon whisper-id)
|
||||
:whisper-identity whisper-id})
|
||||
(defn public-key->new-contact [public-key]
|
||||
{:name (gfycat/generate-gfy public-key)
|
||||
:photo-path (identicon/identicon public-key)
|
||||
:public-key public-key})
|
||||
|
||||
(defn public-key->address [public-key]
|
||||
(let [length (count public-key)
|
||||
|
|
|
@ -115,4 +115,4 @@
|
|||
(->> (map second contacts)
|
||||
(remove (fn [{:keys [dapp? pending?]}]
|
||||
(or pending? dapp?)))
|
||||
(map :whisper-identity)))
|
||||
(map :public-key)))
|
||||
|
|
|
@ -62,13 +62,13 @@
|
|||
(log/info "universal-links: handling public chat " public-chat)
|
||||
(chat/start-public-chat cofx public-chat {:navigation-reset? true}))
|
||||
|
||||
(fx/defn handle-view-profile [{:keys [db] :as cofx} profile-id]
|
||||
(log/info "universal-links: handling view profile" profile-id)
|
||||
(if (new-chat.db/own-whisper-identity? db profile-id)
|
||||
(fx/defn handle-view-profile [{:keys [db] :as cofx} public-key]
|
||||
(log/info "universal-links: handling view profile" public-key)
|
||||
(if (new-chat.db/own-public-key? db public-key)
|
||||
(navigation/navigate-to-cofx cofx :my-profile nil)
|
||||
(if platform/desktop?
|
||||
(desktop.events/show-profile-desktop profile-id cofx)
|
||||
(navigation/navigate-to-cofx (assoc-in cofx [:db :contacts/identity] profile-id) :profile nil))))
|
||||
(desktop.events/show-profile-desktop public-key cofx)
|
||||
(navigation/navigate-to-cofx (assoc-in cofx [:db :contacts/identity] public-key) :profile nil))))
|
||||
|
||||
(fx/defn handle-extension [cofx url]
|
||||
(log/info "universal-links: handling url profile" url)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
:current-chat-id "recipient"
|
||||
:contacts/contacts {"recipient" {:name "Recipient"
|
||||
:address "0xAA"
|
||||
:whisper-identity "0xBB"}}}})
|
||||
:public-key "0xBB"}}}})
|
||||
|
||||
;; testing the `/send` command
|
||||
|
||||
|
|
|
@ -205,33 +205,33 @@
|
|||
:unviewed-messages #{"6" "5" "4" "3" "2" "1"}
|
||||
:message-statuses {"6" {"me" {:message-id "6"
|
||||
:chat-id "status"
|
||||
:whisper-identity "me"
|
||||
:public-key "me"
|
||||
:status :received}}
|
||||
"5" {"me" {:message-id "5"
|
||||
:chat-id "status"
|
||||
:whisper-identity "me"
|
||||
:public-key "me"
|
||||
:status :received}}
|
||||
"4" {"me" {:message-id "4"
|
||||
:chat-id "status"
|
||||
:whisper-identity "me"
|
||||
:public-key "me"
|
||||
:status :received}}}}
|
||||
"opened" {:unviewed-messages #{}
|
||||
:message-statuses {"1" {"me" {:message-id "1"
|
||||
:chat-id "opened"
|
||||
:whisper-identity "me"
|
||||
:public-key "me"
|
||||
:status :seen}}}}
|
||||
"1-1" {:unviewed-messages #{"6" "5" "4" "3" "2" "1"}
|
||||
:message-statuses {"6" {"me" {:message-id "6"
|
||||
:chat-id "status"
|
||||
:whisper-identity "me"
|
||||
:public-key "me"
|
||||
:status :received}}
|
||||
"5" {"me" {:message-id "5"
|
||||
:chat-id "status"
|
||||
:whisper-identity "me"
|
||||
:public-key "me"
|
||||
:status :received}}
|
||||
"4" {"me" {:message-id "4"
|
||||
:chat-id "status"
|
||||
:whisper-identity "me"
|
||||
:public-key "me"
|
||||
:status :received}}}}}})
|
||||
|
||||
(deftest mark-messages-seen
|
||||
|
|
|
@ -32,28 +32,3 @@
|
|||
{:identity "Ethlance"}
|
||||
{:identity "Commiteth"}]
|
||||
:pending? false})
|
||||
|
||||
(def demo-bot-contact
|
||||
{:address nil
|
||||
:name "Demo bot"
|
||||
:description nil
|
||||
:hide-contact? false
|
||||
:dapp-hash nil
|
||||
:photo-path nil
|
||||
:dapp-url nil
|
||||
:bot-url "local://demo-bot"
|
||||
:whisper-identity "demo-bot"
|
||||
:dapp? true
|
||||
:pending? false
|
||||
:unremovable? false
|
||||
:public-key nil})
|
||||
|
||||
(def console-contact
|
||||
{:whisper-identity "console"
|
||||
:name "status-console"
|
||||
:photo-path "contacts://console"
|
||||
:dapp? true
|
||||
:unremovable? true
|
||||
:bot-url "local://console-bot"
|
||||
:status "intro-status"
|
||||
:pending? false})
|
||||
|
|
|
@ -9,25 +9,7 @@
|
|||
(let [chat-contact-ids ["0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"
|
||||
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
|
||||
"0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"]
|
||||
contacts {"demo-bot"
|
||||
{:description nil,
|
||||
:last-updated 0,
|
||||
:hide-contact? false,
|
||||
:address nil,
|
||||
:name "Demo bot",
|
||||
:fcm-token nil,
|
||||
:dapp-url nil,
|
||||
:dapp-hash nil,
|
||||
:photo-path nil,
|
||||
:debug? false,
|
||||
:status nil,
|
||||
:bot-url "local://demo-bot",
|
||||
:pending? false,
|
||||
:whisper-identity "demo-bot",
|
||||
:last-online 0,
|
||||
:dapp? true,
|
||||
:public-key nil},
|
||||
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
|
||||
contacts {"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
|
||||
{:description nil,
|
||||
:last-updated 0,
|
||||
:hide-contact? false,
|
||||
|
@ -41,30 +23,10 @@
|
|||
:status nil,
|
||||
:bot-url nil,
|
||||
:pending? true,
|
||||
:whisper-identity
|
||||
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f",
|
||||
:last-online 0,
|
||||
:dapp? false,
|
||||
:public-key
|
||||
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"},
|
||||
"cryptokitties"
|
||||
{:description "Collect and breed adorable digital cats.",
|
||||
:last-updated 0,
|
||||
:hide-contact? false,
|
||||
:address nil,
|
||||
:name "CryptoKitties",
|
||||
:fcm-token nil,
|
||||
:dapp-url "https://www.cryptokitties.co",
|
||||
:dapp-hash nil,
|
||||
:photo-path "contacts://cryptokitties",
|
||||
:debug? false,
|
||||
:status nil,
|
||||
:bot-url nil,
|
||||
:pending? false,
|
||||
:whisper-identity "cryptokitties",
|
||||
:last-online 0,
|
||||
:dapp? true,
|
||||
:public-key nil}}
|
||||
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}}
|
||||
current-account {:last-updated 0,
|
||||
:address "f23d28f538fd8cd4a90c2d96ca89f5bccca5383f",
|
||||
:signed-up? true,
|
||||
|
@ -78,10 +40,10 @@
|
|||
current-account)
|
||||
[{:name "Snappy Impressive Leonberger"
|
||||
:photo-path "generated"
|
||||
:whisper-identity "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"}
|
||||
:public-key "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"}
|
||||
{:name "User A"
|
||||
:photo-path "photo2"
|
||||
:whisper-identity "0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"}
|
||||
:public-key "0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"}
|
||||
{:description nil
|
||||
:last-updated 0
|
||||
:hide-contact? false
|
||||
|
@ -95,7 +57,6 @@
|
|||
:status nil
|
||||
:bot-url nil
|
||||
:pending? true
|
||||
:whisper-identity "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
|
||||
:last-online 0
|
||||
:dapp? false
|
||||
:public-key "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}]))))))
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
(testing "it stores the contact in the database"
|
||||
(is (:data-store/tx actual)))
|
||||
(testing "it adds a new contact with pending? true"
|
||||
(is (= {:whisper-identity public-key
|
||||
:public-key public-key
|
||||
(is (= {:public-key public-key
|
||||
:photo-path "image"
|
||||
:name "name"
|
||||
:last-updated 1000
|
||||
|
@ -52,8 +51,7 @@
|
|||
:address "new-address"
|
||||
:fcm-token "new-token"}
|
||||
{:db {:contacts/contacts
|
||||
{public-key {:whisper-identity public-key
|
||||
:public-key public-key
|
||||
{public-key {:public-key public-key
|
||||
:photo-path "old-image"
|
||||
:name "old-name"
|
||||
:last-updated 0
|
||||
|
@ -64,8 +62,7 @@
|
|||
(testing "it stores the contact in the database"
|
||||
(is (:data-store/tx actual)))
|
||||
(testing "it updates the contact leaving pending unchanged"
|
||||
(is (= {:whisper-identity public-key
|
||||
:public-key public-key
|
||||
(is (= {:public-key public-key
|
||||
:photo-path "new-image"
|
||||
:name "new-name"
|
||||
:last-updated 1000
|
||||
|
@ -81,8 +78,7 @@
|
|||
:address "new-address"
|
||||
:fcm-token "new-token"}
|
||||
{:db {:contacts/contacts
|
||||
{public-key {:whisper-identity public-key
|
||||
:public-key public-key
|
||||
{public-key {:public-key public-key
|
||||
:photo-path "old-image"
|
||||
:name "old-name"
|
||||
:last-updated 1000
|
||||
|
@ -101,8 +97,7 @@
|
|||
:address "new-address"
|
||||
:fcm-token "new-token"}
|
||||
{:db {:contacts/contacts
|
||||
{public-key {:whisper-identity public-key
|
||||
:public-key public-key
|
||||
{public-key {:public-key public-key
|
||||
:photo-path "old-image"
|
||||
:name "old-name"
|
||||
:last-updated 1000
|
||||
|
@ -119,8 +114,7 @@
|
|||
{:name "new-name"
|
||||
:profile-image "new-image"}
|
||||
{:db {:contacts/contacts
|
||||
{public-key {:whisper-identity public-key
|
||||
:public-key public-key
|
||||
{public-key {:public-key public-key
|
||||
:photo-path "old-image"
|
||||
:name "old-name"
|
||||
:last-updated 0
|
||||
|
@ -129,8 +123,7 @@
|
|||
(testing "it stores the contact in the database"
|
||||
(is (:data-store/tx actual)))
|
||||
(testing "it updates the contact leaving pending unchanged"
|
||||
(is (= {:whisper-identity public-key
|
||||
:public-key public-key
|
||||
(is (= {:public-key public-key
|
||||
:photo-path "new-image"
|
||||
:name "new-name"
|
||||
:last-updated 1000
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
(nodejs/enable-util-print!)
|
||||
|
||||
(def contact-whisper-identity "0x048f7d5d4bda298447bbb5b021a34832509bd1a8dbe4e06f9b7223d00a59b6dc14f6e142b21d3220ceb3155a6d8f40ec115cd96394d3cc7c55055b433a1758dc74")
|
||||
(def contact-public-key "0x048f7d5d4bda298447bbb5b021a34832509bd1a8dbe4e06f9b7223d00a59b6dc14f6e142b21d3220ceb3155a6d8f40ec115cd96394d3cc7c55055b433a1758dc74")
|
||||
(def rpc-url (aget nodejs/process.env "WNODE_ADDRESS"))
|
||||
|
||||
(def Web3 (js/require "web3"))
|
||||
|
@ -41,7 +41,7 @@
|
|||
(rf/reg-fx :data-store.transport/save (constantly nil))
|
||||
(rf/reg-fx :data-store/update-message (constantly nil))
|
||||
|
||||
(rf/dispatch [:contact.ui/send-message-pressed {:whisper-identity contact-whisper-identity}])
|
||||
(rf/dispatch [:contact.ui/send-message-pressed {:public-key contact-public-key}])
|
||||
(rf-test/wait-for [::transport.contact/send-new-sym-key]
|
||||
(rf/dispatch [:set-chat-input-text "test message"])
|
||||
(rf/dispatch [:send-current-message])
|
||||
|
|
Loading…
Reference in New Issue