Wallet Activity: transactions are not sorted by time #20808 (#20862)

This commit is contained in:
mmilad75 2024-07-27 17:22:01 +02:00 committed by GitHub
parent 90653955a6
commit 525609f0af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 72 additions and 41 deletions

View File

@ -115,13 +115,13 @@
(comp :network-name first)) (comp :network-name first))
address-activities (->> (get activities current-viewing-account-address) address-activities (->> (get activities current-viewing-account-address)
(vals) (vals)
(sort :timestamp))] (sort-by :timestamp))]
(->> address-activities (->> address-activities
(keep #(process-activity-by-type chain-id->network-name %)) (keep #(process-activity-by-type chain-id->network-name %))
(group-by (fn [{:keys [timestamp]}] (group-by (fn [{:keys [timestamp]}]
(datetime/timestamp->relative-short-date (* timestamp 1000)))) (datetime/timestamp->relative-short-date (* timestamp 1000))))
(map (fn [[date activities]] (map (fn [[date activities]]
{:title date {:title date
:data activities :data (reverse activities)
:timestamp (:timestamp (first activities))})) :timestamp (:timestamp (first activities))}))
(sort-by (fn [{:keys [timestamp]}] (- timestamp))))))) (sort-by (fn [{:keys [timestamp]}] (- timestamp)))))))

View File

@ -38,48 +38,79 @@
:amount-out "0x1" :amount-out "0x1"
:sender "acc1" :sender "acc1"
:recipient "acc4" :recipient "acc4"
:timestamp 1588464000}} :timestamp 1588464000}
"acc3" {4 {:activity-type constants/wallet-activity-type-receive 4 {:activity-type constants/wallet-activity-type-send
:amount-out "0x1"
:sender "acc1"
:recipient "acc4"
:timestamp 1588464100}
5 {:activity-type constants/wallet-activity-type-send
:amount-out "0x1"
:sender "acc1"
:recipient "acc4"
:timestamp 1588464050}}
"acc3" {6 {:activity-type constants/wallet-activity-type-receive
:amount-in "0x1" :amount-in "0x1"
:sender "acc4" :sender "acc4"
:recipient "acc3" :recipient "acc3"
:timestamp 1588464000}}}) :timestamp 1588464000}}})
(assoc-in [:wallet :current-viewing-account-address] "acc1")))) (assoc-in [:wallet :current-viewing-account-address] "acc1"))))
(is (is
(match? [{:title "May 3, 2020" (match?
:timestamp 1588464000 [{:title "May 3, 2020"
:data [{:relative-date "May 3, 2020" :timestamp 1588464000
:amount "0" :data [{:relative-date "May 3, 2020"
:network-logo nil :amount "0"
:recipient "acc4" :network-logo nil
:transaction :send :recipient "acc4"
:token nil :transaction :send
:network-name nil :token nil
:status nil :network-name nil
:sender "acc1" :status nil
:timestamp 1588464000}]} :sender "acc1"
{:title "May 2, 2020" :timestamp 1588464100}
:timestamp 1588377600 {:relative-date "May 3, 2020"
:data [{:relative-date "May 2, 2020" :amount "0"
:amount "0" :network-logo nil
:network-logo nil :recipient "acc4"
:recipient "acc1" :transaction :send
:transaction :receive :token nil
:token nil :network-name nil
:network-name nil :status nil
:status nil :sender "acc1"
:sender "acc2" :timestamp 1588464050}
:timestamp 1588377600}]} {:relative-date "May 3, 2020"
{:title "May 1, 2020" :amount "0"
:timestamp 1588291200 :network-logo nil
:data [{:relative-date "May 1, 2020" :recipient "acc4"
:amount "0" :transaction :send
:network-logo nil :token nil
:recipient "acc2" :network-name nil
:transaction :send :status nil
:token nil :sender "acc1"
:network-name nil :timestamp 1588464000}]}
:status nil {:title "May 2, 2020"
:sender "acc1" :timestamp 1588377600
:timestamp 1588291200}]}] :data [{:relative-date "May 2, 2020"
(rf/sub [sub-name]))))) :amount "0"
:network-logo nil
:recipient "acc1"
:transaction :receive
:token nil
:network-name nil
:status nil
:sender "acc2"
:timestamp 1588377600}]}
{:title "May 1, 2020"
:timestamp 1588291200
:data [{:relative-date "May 1, 2020"
:amount "0"
:network-logo nil
:recipient "acc2"
:transaction :send
:token nil
:network-name nil
:status nil
:sender "acc1"
:timestamp 1588291200}]}]
(rf/sub [sub-name])))))