[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]
|
||||
[status-im.bots.constants :as bots-constants]))
|
||||
|
||||
(reg-sub
|
||||
:current-contact
|
||||
(reg-sub :current-contact
|
||||
(fn [db [_ k]]
|
||||
(get-in db [:contacts/contacts (:current-chat-id db) k])))
|
||||
|
||||
(reg-sub
|
||||
:get-contacts
|
||||
(reg-sub :get-contacts
|
||||
(fn [db _]
|
||||
(:contacts/contacts db)))
|
||||
|
||||
|
@ -22,8 +20,7 @@
|
|||
(clojure.string/lower-case name2))))
|
||||
(vals contacts)))
|
||||
|
||||
(reg-sub
|
||||
:all-added-contacts
|
||||
(reg-sub :all-added-contacts
|
||||
:<- [:get-contacts]
|
||||
(fn [contacts]
|
||||
(->> (remove (fn [[_ {:keys [pending? whisper-identity]}]]
|
||||
|
@ -31,14 +28,12 @@
|
|||
(bots-constants/hidden-bots whisper-identity))) contacts)
|
||||
(sort-contacts))))
|
||||
|
||||
(reg-sub
|
||||
:all-added-people-contacts
|
||||
(reg-sub :all-added-people-contacts
|
||||
:<- [:all-added-contacts]
|
||||
(fn [contacts]
|
||||
(remove #(true? (:dapp? %)) contacts)))
|
||||
|
||||
(reg-sub
|
||||
:people-in-current-chat
|
||||
(reg-sub :people-in-current-chat
|
||||
:<- [:current-chat-contacts]
|
||||
(fn [contacts]
|
||||
(remove #(true? (:dapp? %)) contacts)))
|
||||
|
@ -47,13 +42,11 @@
|
|||
(let [group-contacts' (into #{} (map #(:identity %) group-contacts))]
|
||||
(filter #(group-contacts' (:whisper-identity %)) contacts)))
|
||||
|
||||
(reg-sub
|
||||
:group-contacts
|
||||
(reg-sub :group-contacts
|
||||
(fn [db [_ group-id]]
|
||||
(get-in db [:group/contact-groups group-id :contacts])))
|
||||
|
||||
(reg-sub
|
||||
:all-added-group-contacts
|
||||
(reg-sub :all-added-group-contacts
|
||||
(fn [[_ group-id] _]
|
||||
[(subscribe [:all-added-contacts])
|
||||
(subscribe [:group-contacts group-id])])
|
||||
|
@ -64,8 +57,7 @@
|
|||
(let [group-contacts' (into #{} (map #(:identity %) group-contacts))]
|
||||
(remove #(group-contacts' (:whisper-identity %)) contacts)))
|
||||
|
||||
(reg-sub
|
||||
:all-not-added-group-contacts
|
||||
(reg-sub :all-not-added-group-contacts
|
||||
(fn [[_ group-id] _]
|
||||
[(subscribe [:all-added-contacts])
|
||||
(subscribe [:group-contacts group-id])])
|
||||
|
@ -79,27 +71,23 @@
|
|||
(fn [contacts [_ group-id limit]]
|
||||
(take limit contacts)))
|
||||
|
||||
(reg-sub
|
||||
:all-added-group-contacts-count
|
||||
(reg-sub :all-added-group-contacts-count
|
||||
(fn [[_ group-id] _]
|
||||
(subscribe [:all-added-group-contacts group-id]))
|
||||
(fn [contacts _]
|
||||
(count contacts)))
|
||||
|
||||
(reg-sub
|
||||
:get-added-contacts-with-limit
|
||||
(reg-sub :get-added-contacts-with-limit
|
||||
:<- [:all-added-contacts]
|
||||
(fn [contacts [_ limit]]
|
||||
(take limit contacts)))
|
||||
|
||||
(reg-sub
|
||||
:added-contacts-count
|
||||
(reg-sub :added-contacts-count
|
||||
:<- [:all-added-contacts]
|
||||
(fn [contacts]
|
||||
(count contacts)))
|
||||
|
||||
(reg-sub
|
||||
:all-added-groups
|
||||
(reg-sub :all-added-groups
|
||||
:<- [:get-contact-groups]
|
||||
(fn [groups]
|
||||
(->> (remove :pending? (vals groups))
|
||||
|
@ -116,8 +104,7 @@
|
|||
(filter #(search-filter text %) contacts)
|
||||
contacts))
|
||||
|
||||
(reg-sub
|
||||
:all-added-group-contacts-filtered
|
||||
(reg-sub :all-added-group-contacts-filtered
|
||||
(fn [[_ group-id] _]
|
||||
[(if group-id
|
||||
(subscribe [:all-added-group-contacts group-id])
|
||||
|
@ -126,60 +113,51 @@
|
|||
(fn [[contacts text] _]
|
||||
(search-filter-reaction contacts text)))
|
||||
|
||||
(reg-sub
|
||||
:contact-group-contacts
|
||||
(reg-sub :contact-group-contacts
|
||||
:<- [:get-contact-group]
|
||||
(fn [group]
|
||||
(:contacts group)))
|
||||
|
||||
(reg-sub
|
||||
:all-not-added-contact-group-contacts
|
||||
(reg-sub :all-not-added-contact-group-contacts
|
||||
(fn [_ _]
|
||||
[(subscribe [:all-added-contacts])
|
||||
(subscribe [:contact-group-contacts])])
|
||||
(fn [[contacts group-contacts]]
|
||||
(filter-not-group-contacts group-contacts contacts)))
|
||||
|
||||
(reg-sub
|
||||
:all-group-not-added-contacts-filtered
|
||||
(reg-sub :all-group-not-added-contacts-filtered
|
||||
(fn [_ _]
|
||||
[(subscribe [:all-not-added-contact-group-contacts])
|
||||
(subscribe [:get-in [:toolbar-search :text]])])
|
||||
(fn [[contacts text] _]
|
||||
(search-filter-reaction contacts text)))
|
||||
|
||||
(reg-sub
|
||||
:contacts-filtered
|
||||
(reg-sub :contacts-filtered
|
||||
(fn [[_ subscription-id] _]
|
||||
[(subscribe [subscription-id])
|
||||
(subscribe [:get-in [:toolbar-search :text]])])
|
||||
(fn [[contacts text]]
|
||||
(search-filter-reaction contacts text)))
|
||||
|
||||
(reg-sub
|
||||
:contact
|
||||
(reg-sub :contact
|
||||
(fn [db]
|
||||
(let [identity (:contacts/identity db)]
|
||||
(get-in db [:contacts/contacts identity]))))
|
||||
|
||||
(reg-sub
|
||||
:contact-by-identity
|
||||
(reg-sub :contact-by-identity
|
||||
(fn [db [_ identity]]
|
||||
(get-in db [:contacts/contacts identity])))
|
||||
|
||||
(reg-sub
|
||||
:contact-name-by-identity
|
||||
(reg-sub :contact-name-by-identity
|
||||
:<- [:get-contacts]
|
||||
(fn [contacts [_ identity]]
|
||||
(:name (contacts identity))))
|
||||
|
||||
(reg-sub
|
||||
:chat-by-id
|
||||
(reg-sub :chat-by-id
|
||||
(fn [db [_ chat-id]]
|
||||
(get-in db [:chats chat-id])))
|
||||
|
||||
(reg-sub
|
||||
:current-chat
|
||||
(reg-sub :current-chat
|
||||
(fn [db _]
|
||||
(get-in db [:chats (:current-chat-id db)])))
|
||||
|
||||
|
@ -192,33 +170,28 @@
|
|||
(fn #(current-participants (:whisper-identity %))
|
||||
(vals contacts)))))
|
||||
|
||||
(reg-sub
|
||||
:contacts-current-chat
|
||||
(reg-sub :contacts-current-chat
|
||||
:<- [:current-chat]
|
||||
:<- [:get-contacts]
|
||||
chat-contacts)
|
||||
|
||||
(reg-sub
|
||||
:all-new-contacts
|
||||
(reg-sub :all-new-contacts
|
||||
:<- [:contacts-current-chat remove]
|
||||
(fn [contacts]
|
||||
contacts))
|
||||
|
||||
(reg-sub
|
||||
:current-chat-contacts
|
||||
(reg-sub :current-chat-contacts
|
||||
:<- [:contacts-current-chat filter]
|
||||
(fn [contacts]
|
||||
contacts))
|
||||
|
||||
(reg-sub
|
||||
:contacts-by-chat
|
||||
(reg-sub :contacts-by-chat
|
||||
(fn [[_ fn chat-id] _]
|
||||
[(subscribe [:chat-by-id chat-id])
|
||||
(subscribe [:get-contacts])])
|
||||
chat-contacts)
|
||||
|
||||
(reg-sub
|
||||
:chat-photo
|
||||
(reg-sub :chat-photo
|
||||
(fn [[_ chat-id] _]
|
||||
[(if chat-id
|
||||
(subscribe [:chat-by-id chat-id])
|
||||
|
@ -234,4 +207,14 @@
|
|||
(:photo-path (first contacts))
|
||||
|
||||
: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]
|
||||
(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
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(:transactions wallet)))
|
||||
:<- [:contacts/by-address]
|
||||
(fn [[wallet contacts]]
|
||||
(reduce (fn [acc [hash transaction]]
|
||||
(assoc acc hash (enrich-transaction transaction contacts)))
|
||||
{}
|
||||
(:transactions wallet))))
|
||||
|
||||
(reg-sub :wallet.transactions/grouped-transactions
|
||||
:<- [:wallet.transactions/transactions]
|
||||
|
@ -40,8 +55,10 @@
|
|||
:hash id))
|
||||
|
||||
(reg-sub :wallet/unsigned-transactions
|
||||
(fn [db]
|
||||
(vals (get-in db [:wallet :transactions-unsigned]))))
|
||||
:<- [:wallet]
|
||||
:<- [:contacts/by-address]
|
||||
(fn [[wallet contacts]]
|
||||
(map #(enrich-transaction % contacts) (vals (:transactions-unsigned wallet)))))
|
||||
|
||||
(reg-sub :wallet.transactions/unsigned-transactions
|
||||
:<- [:wallet/unsigned-transactions]
|
||||
|
@ -127,11 +144,7 @@
|
|||
:nonce (i18n/label :not-applicable)
|
||||
:hash (i18n/label :not-applicable)}
|
||||
{:cost (money/wei->str :eth (money/fee-value gas-used gas-price))
|
||||
: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"})))))
|
||||
:url (transactions/get-transaction-details-url network hash)})))))
|
||||
|
||||
(reg-sub :wallet.transactions.details/confirmations
|
||||
:<- [:wallet.transactions/transaction-details]
|
||||
|
@ -147,15 +160,8 @@
|
|||
100
|
||||
(* 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
|
||||
:<- [:contacts-by-address]
|
||||
:<- [:contacts/by-address]
|
||||
(fn [contacts [_ address]]
|
||||
(let [address' (when address
|
||||
(utils.hex/normalize-hex address))]
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
(:postponed :pending) (transaction-icon :icons/arrow-right styles/color-gray4-transparent styles/color-gray7)
|
||||
(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])
|
||||
[react/view
|
||||
[list/item
|
||||
|
@ -84,8 +84,8 @@
|
|||
[list/item-content
|
||||
(money/wei->str :eth value)
|
||||
(if (inbound? type)
|
||||
(str (i18n/label :t/from) " " from)
|
||||
(str (i18n/label :t/to) " " to))
|
||||
(str (i18n/label :t/from) " " from-contact " " from)
|
||||
(str (i18n/label :t/to) " " to-contact " " to))
|
||||
(when (unsigned? type)
|
||||
[action-buttons transaction])]
|
||||
[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-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}
|
||||
[details-list-row :t/block block]
|
||||
[details-list-row :t/hash hash]
|
||||
[details-list-row :t/from (or from-wallet from) (when from-wallet from)]
|
||||
[details-list-row :t/to (or to-wallet to) (when to-wallet to)]
|
||||
[details-list-row :t/from
|
||||
(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-price gas-price-gwei gas-price-eth]
|
||||
[details-list-row :t/gas-used gas-used]
|
||||
|
|
Loading…
Reference in New Issue