[bug] fix order of transactions in sections of transactions history
order should be latest transaction first
This commit is contained in:
parent
d022c286bb
commit
e66ae8b388
|
@ -66,18 +66,20 @@
|
||||||
:key :pending
|
:key :pending
|
||||||
:data pending})))
|
:data pending})))
|
||||||
|
|
||||||
|
(defn group-transactions-by-date [transactions]
|
||||||
|
(->> transactions
|
||||||
|
(group-by #(datetime/timestamp->date-key (:timestamp %)))
|
||||||
|
(sort-by key)
|
||||||
|
reverse
|
||||||
|
(map (fn [[date-key transactions]]
|
||||||
|
{:title (datetime/timestamp->mini-date (:timestamp (first transactions)))
|
||||||
|
:key date-key
|
||||||
|
:data (sort-by :timestamp > transactions)}))))
|
||||||
|
|
||||||
(reg-sub :wallet.transactions/completed-transactions-list
|
(reg-sub :wallet.transactions/completed-transactions-list
|
||||||
:<- [:wallet.transactions/grouped-transactions]
|
:<- [:wallet.transactions/grouped-transactions]
|
||||||
(fn [{:keys [inbound outbound]}]
|
(fn [{:keys [inbound outbound]}]
|
||||||
(->> (into inbound outbound)
|
(group-transactions-by-date (into inbound outbound))))
|
||||||
(group-by #(datetime/timestamp->date-key (:timestamp %)))
|
|
||||||
(sort-by key)
|
|
||||||
reverse
|
|
||||||
(map (fn [[k v]]
|
|
||||||
{:title (datetime/timestamp->mini-date (:timestamp (first v)))
|
|
||||||
:key k
|
|
||||||
;; TODO (yenda investigate wether this sort-by is necessary or not)
|
|
||||||
:data (sort-by :timestamp v)})))))
|
|
||||||
|
|
||||||
(reg-sub :wallet.transactions/transactions-history-list
|
(reg-sub :wallet.transactions/transactions-history-list
|
||||||
:<- [:wallet.transactions/postponed-transactions-list]
|
:<- [:wallet.transactions/postponed-transactions-list]
|
||||||
|
@ -114,7 +116,7 @@
|
||||||
:nonce (i18n/label :not-applicable)}
|
:nonce (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 impletmented
|
;; TODO (yenda) proper wallet logic when wallet switching is implemented
|
||||||
(if (= type :inbound)
|
(if (= type :inbound)
|
||||||
{:to-wallet "Main wallet"}
|
{:to-wallet "Main wallet"}
|
||||||
{:from-wallet "Main wallet"})))))
|
{:from-wallet "Main wallet"})))))
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
[status-im.test.contacts.events]
|
[status-im.test.contacts.events]
|
||||||
[status-im.test.accounts.events]
|
[status-im.test.accounts.events]
|
||||||
[status-im.test.wallet.events]
|
[status-im.test.wallet.events]
|
||||||
|
[status-im.test.wallet.transactions.subs]
|
||||||
[status-im.test.profile.events]
|
[status-im.test.profile.events]
|
||||||
[status-im.test.chat.models.input]
|
[status-im.test.chat.models.input]
|
||||||
[status-im.test.components.main-tabs]
|
[status-im.test.components.main-tabs]
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
'status-im.test.contacts.events
|
'status-im.test.contacts.events
|
||||||
'status-im.test.profile.events
|
'status-im.test.profile.events
|
||||||
'status-im.test.wallet.events
|
'status-im.test.wallet.events
|
||||||
|
'status-im.test.wallet.transactions.subs
|
||||||
'status-im.test.chat.models.input
|
'status-im.test.chat.models.input
|
||||||
'status-im.test.components.main-tabs
|
'status-im.test.components.main-tabs
|
||||||
'status-im.test.handlers
|
'status-im.test.handlers
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
(ns status-im.test.wallet.transactions.subs
|
||||||
|
(:require [cljs.test :refer [deftest is testing]]
|
||||||
|
reagent.core
|
||||||
|
[re-frame.core :as re-frame]
|
||||||
|
[day8.re-frame.test :refer [run-test-sync]]
|
||||||
|
status-im.ui.screens.db
|
||||||
|
status-im.ui.screens.subs
|
||||||
|
[status-im.ui.screens.events :as events]
|
||||||
|
[status-im.ui.screens.wallet.transactions.subs :as transactions-subs]))
|
||||||
|
|
||||||
|
(def transactions [{:timestamp "1505912551000"}
|
||||||
|
{:timestamp "1505764322000"}
|
||||||
|
{:timestamp "1505750000000"}])
|
||||||
|
|
||||||
|
(def grouped-transactions '({:title "20 Sep"
|
||||||
|
:key :20170920
|
||||||
|
:data
|
||||||
|
({:timestamp "1505912551000"})}
|
||||||
|
{:title "18 Sep"
|
||||||
|
:key :20170918
|
||||||
|
:data
|
||||||
|
({:timestamp "1505764322000"}
|
||||||
|
{:timestamp "1505750000000"})}))
|
||||||
|
|
||||||
|
|
||||||
|
(deftest group-transactions-by-date
|
||||||
|
"Check if transactions are sorted by date"
|
||||||
|
(is (= (transactions-subs/group-transactions-by-date transactions)
|
||||||
|
grouped-transactions)))
|
Loading…
Reference in New Issue