[Feature] #2040 Show Recipient name if available in Unsigned/History
This commit is contained in:
parent
5fcf482ef0
commit
10cfef3bdb
|
@ -4,13 +4,11 @@
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[status-im.bots.constants :as bots-constants]))
|
[status-im.bots.constants :as bots-constants]))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :current-contact
|
||||||
:current-contact
|
|
||||||
(fn [db [_ k]]
|
(fn [db [_ k]]
|
||||||
(get-in db [:contacts/contacts (:current-chat-id db) k])))
|
(get-in db [:contacts/contacts (:current-chat-id db) k])))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :get-contacts
|
||||||
:get-contacts
|
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(:contacts/contacts db)))
|
(:contacts/contacts db)))
|
||||||
|
|
||||||
|
@ -22,8 +20,7 @@
|
||||||
(clojure.string/lower-case name2))))
|
(clojure.string/lower-case name2))))
|
||||||
(vals contacts)))
|
(vals contacts)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :all-added-contacts
|
||||||
:all-added-contacts
|
|
||||||
:<- [:get-contacts]
|
:<- [:get-contacts]
|
||||||
(fn [contacts]
|
(fn [contacts]
|
||||||
(->> (remove (fn [[_ {:keys [pending? whisper-identity]}]]
|
(->> (remove (fn [[_ {:keys [pending? whisper-identity]}]]
|
||||||
|
@ -31,14 +28,12 @@
|
||||||
(bots-constants/hidden-bots whisper-identity))) contacts)
|
(bots-constants/hidden-bots whisper-identity))) contacts)
|
||||||
(sort-contacts))))
|
(sort-contacts))))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :all-added-people-contacts
|
||||||
:all-added-people-contacts
|
|
||||||
:<- [:all-added-contacts]
|
:<- [:all-added-contacts]
|
||||||
(fn [contacts]
|
(fn [contacts]
|
||||||
(remove #(true? (:dapp? %)) contacts)))
|
(remove #(true? (:dapp? %)) contacts)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :people-in-current-chat
|
||||||
:people-in-current-chat
|
|
||||||
:<- [:current-chat-contacts]
|
:<- [:current-chat-contacts]
|
||||||
(fn [contacts]
|
(fn [contacts]
|
||||||
(remove #(true? (:dapp? %)) contacts)))
|
(remove #(true? (:dapp? %)) contacts)))
|
||||||
|
@ -47,13 +42,11 @@
|
||||||
(let [group-contacts' (into #{} (map #(:identity %) group-contacts))]
|
(let [group-contacts' (into #{} (map #(:identity %) group-contacts))]
|
||||||
(filter #(group-contacts' (:whisper-identity %)) contacts)))
|
(filter #(group-contacts' (:whisper-identity %)) contacts)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :group-contacts
|
||||||
:group-contacts
|
|
||||||
(fn [db [_ group-id]]
|
(fn [db [_ group-id]]
|
||||||
(get-in db [:group/contact-groups group-id :contacts])))
|
(get-in db [:group/contact-groups group-id :contacts])))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :all-added-group-contacts
|
||||||
:all-added-group-contacts
|
|
||||||
(fn [[_ group-id] _]
|
(fn [[_ group-id] _]
|
||||||
[(subscribe [:all-added-contacts])
|
[(subscribe [:all-added-contacts])
|
||||||
(subscribe [:group-contacts group-id])])
|
(subscribe [:group-contacts group-id])])
|
||||||
|
@ -64,8 +57,7 @@
|
||||||
(let [group-contacts' (into #{} (map #(:identity %) group-contacts))]
|
(let [group-contacts' (into #{} (map #(:identity %) group-contacts))]
|
||||||
(remove #(group-contacts' (:whisper-identity %)) contacts)))
|
(remove #(group-contacts' (:whisper-identity %)) contacts)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :all-not-added-group-contacts
|
||||||
:all-not-added-group-contacts
|
|
||||||
(fn [[_ group-id] _]
|
(fn [[_ group-id] _]
|
||||||
[(subscribe [:all-added-contacts])
|
[(subscribe [:all-added-contacts])
|
||||||
(subscribe [:group-contacts group-id])])
|
(subscribe [:group-contacts group-id])])
|
||||||
|
@ -79,27 +71,23 @@
|
||||||
(fn [contacts [_ group-id limit]]
|
(fn [contacts [_ group-id limit]]
|
||||||
(take limit contacts)))
|
(take limit contacts)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :all-added-group-contacts-count
|
||||||
:all-added-group-contacts-count
|
|
||||||
(fn [[_ group-id] _]
|
(fn [[_ group-id] _]
|
||||||
(subscribe [:all-added-group-contacts group-id]))
|
(subscribe [:all-added-group-contacts group-id]))
|
||||||
(fn [contacts _]
|
(fn [contacts _]
|
||||||
(count contacts)))
|
(count contacts)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :get-added-contacts-with-limit
|
||||||
:get-added-contacts-with-limit
|
|
||||||
:<- [:all-added-contacts]
|
:<- [:all-added-contacts]
|
||||||
(fn [contacts [_ limit]]
|
(fn [contacts [_ limit]]
|
||||||
(take limit contacts)))
|
(take limit contacts)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :added-contacts-count
|
||||||
:added-contacts-count
|
|
||||||
:<- [:all-added-contacts]
|
:<- [:all-added-contacts]
|
||||||
(fn [contacts]
|
(fn [contacts]
|
||||||
(count contacts)))
|
(count contacts)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :all-added-groups
|
||||||
:all-added-groups
|
|
||||||
:<- [:get-contact-groups]
|
:<- [:get-contact-groups]
|
||||||
(fn [groups]
|
(fn [groups]
|
||||||
(->> (remove :pending? (vals groups))
|
(->> (remove :pending? (vals groups))
|
||||||
|
@ -116,8 +104,7 @@
|
||||||
(filter #(search-filter text %) contacts)
|
(filter #(search-filter text %) contacts)
|
||||||
contacts))
|
contacts))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :all-added-group-contacts-filtered
|
||||||
:all-added-group-contacts-filtered
|
|
||||||
(fn [[_ group-id] _]
|
(fn [[_ group-id] _]
|
||||||
[(if group-id
|
[(if group-id
|
||||||
(subscribe [:all-added-group-contacts group-id])
|
(subscribe [:all-added-group-contacts group-id])
|
||||||
|
@ -126,60 +113,51 @@
|
||||||
(fn [[contacts text] _]
|
(fn [[contacts text] _]
|
||||||
(search-filter-reaction contacts text)))
|
(search-filter-reaction contacts text)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :contact-group-contacts
|
||||||
:contact-group-contacts
|
|
||||||
:<- [:get-contact-group]
|
:<- [:get-contact-group]
|
||||||
(fn [group]
|
(fn [group]
|
||||||
(:contacts group)))
|
(:contacts group)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :all-not-added-contact-group-contacts
|
||||||
:all-not-added-contact-group-contacts
|
|
||||||
(fn [_ _]
|
(fn [_ _]
|
||||||
[(subscribe [:all-added-contacts])
|
[(subscribe [:all-added-contacts])
|
||||||
(subscribe [:contact-group-contacts])])
|
(subscribe [:contact-group-contacts])])
|
||||||
(fn [[contacts group-contacts]]
|
(fn [[contacts group-contacts]]
|
||||||
(filter-not-group-contacts group-contacts contacts)))
|
(filter-not-group-contacts group-contacts contacts)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :all-group-not-added-contacts-filtered
|
||||||
:all-group-not-added-contacts-filtered
|
|
||||||
(fn [_ _]
|
(fn [_ _]
|
||||||
[(subscribe [:all-not-added-contact-group-contacts])
|
[(subscribe [:all-not-added-contact-group-contacts])
|
||||||
(subscribe [:get-in [:toolbar-search :text]])])
|
(subscribe [:get-in [:toolbar-search :text]])])
|
||||||
(fn [[contacts text] _]
|
(fn [[contacts text] _]
|
||||||
(search-filter-reaction contacts text)))
|
(search-filter-reaction contacts text)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :contacts-filtered
|
||||||
:contacts-filtered
|
|
||||||
(fn [[_ subscription-id] _]
|
(fn [[_ subscription-id] _]
|
||||||
[(subscribe [subscription-id])
|
[(subscribe [subscription-id])
|
||||||
(subscribe [:get-in [:toolbar-search :text]])])
|
(subscribe [:get-in [:toolbar-search :text]])])
|
||||||
(fn [[contacts text]]
|
(fn [[contacts text]]
|
||||||
(search-filter-reaction contacts text)))
|
(search-filter-reaction contacts text)))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :contact
|
||||||
:contact
|
|
||||||
(fn [db]
|
(fn [db]
|
||||||
(let [identity (:contacts/identity db)]
|
(let [identity (:contacts/identity db)]
|
||||||
(get-in db [:contacts/contacts identity]))))
|
(get-in db [:contacts/contacts identity]))))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :contact-by-identity
|
||||||
:contact-by-identity
|
|
||||||
(fn [db [_ identity]]
|
(fn [db [_ identity]]
|
||||||
(get-in db [:contacts/contacts identity])))
|
(get-in db [:contacts/contacts identity])))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :contact-name-by-identity
|
||||||
:contact-name-by-identity
|
|
||||||
:<- [:get-contacts]
|
:<- [:get-contacts]
|
||||||
(fn [contacts [_ identity]]
|
(fn [contacts [_ identity]]
|
||||||
(:name (contacts identity))))
|
(:name (contacts identity))))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :chat-by-id
|
||||||
:chat-by-id
|
|
||||||
(fn [db [_ chat-id]]
|
(fn [db [_ chat-id]]
|
||||||
(get-in db [:chats chat-id])))
|
(get-in db [:chats chat-id])))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :current-chat
|
||||||
:current-chat
|
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(get-in db [:chats (:current-chat-id db)])))
|
(get-in db [:chats (:current-chat-id db)])))
|
||||||
|
|
||||||
|
@ -192,33 +170,28 @@
|
||||||
(fn #(current-participants (:whisper-identity %))
|
(fn #(current-participants (:whisper-identity %))
|
||||||
(vals contacts)))))
|
(vals contacts)))))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :contacts-current-chat
|
||||||
:contacts-current-chat
|
|
||||||
:<- [:current-chat]
|
:<- [:current-chat]
|
||||||
:<- [:get-contacts]
|
:<- [:get-contacts]
|
||||||
chat-contacts)
|
chat-contacts)
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :all-new-contacts
|
||||||
:all-new-contacts
|
|
||||||
:<- [:contacts-current-chat remove]
|
:<- [:contacts-current-chat remove]
|
||||||
(fn [contacts]
|
(fn [contacts]
|
||||||
contacts))
|
contacts))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :current-chat-contacts
|
||||||
:current-chat-contacts
|
|
||||||
:<- [:contacts-current-chat filter]
|
:<- [:contacts-current-chat filter]
|
||||||
(fn [contacts]
|
(fn [contacts]
|
||||||
contacts))
|
contacts))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :contacts-by-chat
|
||||||
:contacts-by-chat
|
|
||||||
(fn [[_ fn chat-id] _]
|
(fn [[_ fn chat-id] _]
|
||||||
[(subscribe [:chat-by-id chat-id])
|
[(subscribe [:chat-by-id chat-id])
|
||||||
(subscribe [:get-contacts])])
|
(subscribe [:get-contacts])])
|
||||||
chat-contacts)
|
chat-contacts)
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub :chat-photo
|
||||||
:chat-photo
|
|
||||||
(fn [[_ chat-id] _]
|
(fn [[_ chat-id] _]
|
||||||
[(if chat-id
|
[(if chat-id
|
||||||
(subscribe [:chat-by-id chat-id])
|
(subscribe [:chat-by-id chat-id])
|
||||||
|
@ -234,4 +207,14 @@
|
||||||
(:photo-path (first contacts))
|
(:photo-path (first contacts))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(identicon chat-id)))))
|
(identicon chat-id)))))
|
||||||
|
|
||||||
|
(reg-sub :contacts/by-address
|
||||||
|
:<- [:get-contacts]
|
||||||
|
(fn [contacts]
|
||||||
|
(reduce (fn [acc [_ {:keys [address] :as contact}]]
|
||||||
|
(if address
|
||||||
|
(assoc acc address contact)
|
||||||
|
acc))
|
||||||
|
{}
|
||||||
|
contacts)))
|
||||||
|
|
|
@ -21,10 +21,25 @@
|
||||||
(fn [wallet]
|
(fn [wallet]
|
||||||
(get wallet :current-tab 0)))
|
(get wallet :current-tab 0)))
|
||||||
|
|
||||||
|
(defn enrich-transaction [{:keys [type to from] :as transaction} contacts]
|
||||||
|
;; TODO (yenda) proper wallet logic when wallet switching is implemented
|
||||||
|
(let [[contact-address key-contact key-wallet] (if (= type :inbound)
|
||||||
|
[from :from-contact :to-wallet]
|
||||||
|
[to :to-contact :from-wallet])
|
||||||
|
wallet (i18n/label :main-wallet)
|
||||||
|
contact (get contacts (utils.hex/normalize-hex contact-address))]
|
||||||
|
(cond-> transaction
|
||||||
|
contact (assoc key-contact (:name contact))
|
||||||
|
:always (assoc key-wallet wallet))))
|
||||||
|
|
||||||
(reg-sub :wallet.transactions/transactions
|
(reg-sub :wallet.transactions/transactions
|
||||||
:<- [:wallet]
|
:<- [:wallet]
|
||||||
(fn [wallet]
|
:<- [:contacts/by-address]
|
||||||
(:transactions wallet)))
|
(fn [[wallet contacts]]
|
||||||
|
(reduce (fn [acc [hash transaction]]
|
||||||
|
(assoc acc hash (enrich-transaction transaction contacts)))
|
||||||
|
{}
|
||||||
|
(:transactions wallet))))
|
||||||
|
|
||||||
(reg-sub :wallet.transactions/grouped-transactions
|
(reg-sub :wallet.transactions/grouped-transactions
|
||||||
:<- [:wallet.transactions/transactions]
|
:<- [:wallet.transactions/transactions]
|
||||||
|
@ -40,8 +55,10 @@
|
||||||
:hash id))
|
:hash id))
|
||||||
|
|
||||||
(reg-sub :wallet/unsigned-transactions
|
(reg-sub :wallet/unsigned-transactions
|
||||||
(fn [db]
|
:<- [:wallet]
|
||||||
(vals (get-in db [:wallet :transactions-unsigned]))))
|
:<- [:contacts/by-address]
|
||||||
|
(fn [[wallet contacts]]
|
||||||
|
(map #(enrich-transaction % contacts) (vals (:transactions-unsigned wallet)))))
|
||||||
|
|
||||||
(reg-sub :wallet.transactions/unsigned-transactions
|
(reg-sub :wallet.transactions/unsigned-transactions
|
||||||
:<- [:wallet/unsigned-transactions]
|
:<- [:wallet/unsigned-transactions]
|
||||||
|
@ -127,11 +144,7 @@
|
||||||
:nonce (i18n/label :not-applicable)
|
:nonce (i18n/label :not-applicable)
|
||||||
:hash (i18n/label :not-applicable)}
|
:hash (i18n/label :not-applicable)}
|
||||||
{:cost (money/wei->str :eth (money/fee-value gas-used gas-price))
|
{:cost (money/wei->str :eth (money/fee-value gas-used gas-price))
|
||||||
:url (transactions/get-transaction-details-url network hash)})
|
:url (transactions/get-transaction-details-url network hash)})))))
|
||||||
;; TODO (yenda) proper wallet logic when wallet switching is implemented
|
|
||||||
(if (= type :inbound)
|
|
||||||
{:to-wallet "Main wallet"}
|
|
||||||
{:from-wallet "Main wallet"})))))
|
|
||||||
|
|
||||||
(reg-sub :wallet.transactions.details/confirmations
|
(reg-sub :wallet.transactions.details/confirmations
|
||||||
:<- [:wallet.transactions/transaction-details]
|
:<- [:wallet.transactions/transaction-details]
|
||||||
|
@ -147,15 +160,8 @@
|
||||||
100
|
100
|
||||||
(* 100 (/ confirmations max-confirmations))))))
|
(* 100 (/ confirmations max-confirmations))))))
|
||||||
|
|
||||||
(reg-sub :contacts-by-address
|
|
||||||
(fn [db]
|
|
||||||
(into {} (map (fn [[_ {:keys [address] :as contact}]]
|
|
||||||
(when address
|
|
||||||
[address contact]))
|
|
||||||
(:contacts/contacts db)))))
|
|
||||||
|
|
||||||
(reg-sub :contact-by-address
|
(reg-sub :contact-by-address
|
||||||
:<- [:contacts-by-address]
|
:<- [:contacts/by-address]
|
||||||
(fn [contacts [_ address]]
|
(fn [contacts [_ address]]
|
||||||
(let [address' (when address
|
(let [address' (when address
|
||||||
(utils.hex/normalize-hex address))]
|
(utils.hex/normalize-hex address))]
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
(:postponed :pending) (transaction-icon :icons/arrow-right styles/color-gray4-transparent styles/color-gray7)
|
(:postponed :pending) (transaction-icon :icons/arrow-right styles/color-gray4-transparent styles/color-gray7)
|
||||||
(throw (str "Unknown transaction type: " k))))
|
(throw (str "Unknown transaction type: " k))))
|
||||||
|
|
||||||
(defn render-transaction [{:keys [hash to from type value symbol] :as transaction}]
|
(defn render-transaction [{:keys [hash from-contact to-contact to from type value symbol] :as transaction}]
|
||||||
[list/touchable-item #(re-frame/dispatch [:show-transaction-details hash])
|
[list/touchable-item #(re-frame/dispatch [:show-transaction-details hash])
|
||||||
[react/view
|
[react/view
|
||||||
[list/item
|
[list/item
|
||||||
|
@ -84,8 +84,8 @@
|
||||||
[list/item-content
|
[list/item-content
|
||||||
(money/wei->str :eth value)
|
(money/wei->str :eth value)
|
||||||
(if (inbound? type)
|
(if (inbound? type)
|
||||||
(str (i18n/label :t/from) " " from)
|
(str (i18n/label :t/from) " " from-contact " " from)
|
||||||
(str (i18n/label :t/to) " " to))
|
(str (i18n/label :t/to) " " to-contact " " to))
|
||||||
(when (unsigned? type)
|
(when (unsigned? type)
|
||||||
[action-buttons transaction])]
|
[action-buttons transaction])]
|
||||||
[list/item-icon {:icon :icons/forward
|
[list/item-icon {:icon :icons/forward
|
||||||
|
@ -239,12 +239,19 @@
|
||||||
[react/text {:style transactions.styles/details-item-value} (str value)]
|
[react/text {:style transactions.styles/details-item-value} (str value)]
|
||||||
[react/text {:style transactions.styles/details-item-extra-value} (str extra-value)]]]))
|
[react/text {:style transactions.styles/details-item-extra-value} (str extra-value)]]]))
|
||||||
|
|
||||||
(defn details-list [{:keys [block hash from from-wallet to to-wallet gas-limit gas-price-gwei gas-price-eth gas-used cost nonce data]}]
|
(defn details-list [{:keys [block hash
|
||||||
|
from from-wallet from-contact
|
||||||
|
to to-wallet to-contact
|
||||||
|
gas-limit gas-price-gwei gas-price-eth gas-used cost nonce data]}]
|
||||||
[react/view {:style transactions.styles/details-block}
|
[react/view {:style transactions.styles/details-block}
|
||||||
[details-list-row :t/block block]
|
[details-list-row :t/block block]
|
||||||
[details-list-row :t/hash hash]
|
[details-list-row :t/hash hash]
|
||||||
[details-list-row :t/from (or from-wallet from) (when from-wallet from)]
|
[details-list-row :t/from
|
||||||
[details-list-row :t/to (or to-wallet to) (when to-wallet to)]
|
(or from-wallet from-contact from)
|
||||||
|
(when (or from-wallet from-contact) from)]
|
||||||
|
[details-list-row :t/to
|
||||||
|
(or to-wallet to-contact to)
|
||||||
|
(when (or to-wallet to-contact) to)]
|
||||||
[details-list-row :t/gas-limit gas-limit]
|
[details-list-row :t/gas-limit gas-limit]
|
||||||
[details-list-row :t/gas-price gas-price-gwei gas-price-eth]
|
[details-list-row :t/gas-price gas-price-gwei gas-price-eth]
|
||||||
[details-list-row :t/gas-used gas-used]
|
[details-list-row :t/gas-used gas-used]
|
||||||
|
|
Loading…
Reference in New Issue