-
Notifications
You must be signed in to change notification settings - Fork 985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wallet: Activity Items - Sections #19906
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a8468fa
lint
OmarBasem 7c2f0ad
lint
OmarBasem b12611b
lint
OmarBasem 7addc56
lint
OmarBasem 44a5d81
review
OmarBasem 53fcb19
review
OmarBasem 94c8731
review
OmarBasem f02af38
lint
OmarBasem 23997d7
lint
OmarBasem 36da5ca
lint
OmarBasem 5df8047
lint
OmarBasem 28d9627
fix test
OmarBasem a00cd0e
lint
OmarBasem 57b086a
lint
OmarBasem 8e4e492
lint
OmarBasem b874aef
lint
OmarBasem ba6772e
lint
OmarBasem c8f2375
fix test
OmarBasem 30557da
lint
OmarBasem 4e0c883
lint
OmarBasem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
(ns status-im.subs.wallet.activities | ||
(:require [re-frame.core :as rf])) | ||
(:require | ||
[re-frame.core :as rf] | ||
[status-im.contexts.wallet.common.activity-tab.constants :as constants] | ||
[utils.datetime :as datetime])) | ||
|
||
(rf/reg-sub | ||
:wallet/all-activities | ||
:<- [:wallet] | ||
:-> :activities) | ||
|
||
(rf/reg-sub | ||
:wallet/activities-for-current-viewing-account | ||
(rf/reg-sub :wallet/activities-for-current-viewing-account | ||
:<- [:wallet/all-activities] | ||
:<- [:wallet/current-viewing-account-address] | ||
(fn [[activities current-viewing-account-address]] | ||
(filter (fn [{:keys [sender recipient]}] | ||
(or (= sender current-viewing-account-address) | ||
(= recipient current-viewing-account-address))) | ||
activities))) | ||
(->> activities | ||
(filter (fn [{:keys [sender recipient activity-type]}] | ||
(let [receiving-activity? (= activity-type constants/wallet-activity-type-receive) | ||
relevant-address (if receiving-activity? recipient sender)] | ||
(= relevant-address current-viewing-account-address)))) | ||
(distinct) | ||
(group-by (fn [{:keys [timestamp]}] | ||
(datetime/timestamp->relative-short-date (* timestamp 1000)))) | ||
(map (fn [[date activities]] | ||
{:title date :data activities :timestamp (:timestamp (first activities))})) | ||
(sort-by (fn [{:keys [timestamp]}] (- timestamp)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(ns status-im.subs.wallet.activities-test | ||
(:require | ||
[cljs.test :refer [is testing]] | ||
[re-frame.db :as rf-db] | ||
status-im.subs.root | ||
status-im.subs.wallet.collectibles | ||
[test-helpers.unit :as h] | ||
[utils.re-frame :as rf])) | ||
|
||
(h/deftest-sub :wallet/all-activities | ||
[sub-name] | ||
(testing "Return the activities list from wallet data" | ||
(swap! rf-db/app-db assoc-in | ||
[:wallet :activities] | ||
[{:id 1 :name "Transaction1"} | ||
{:id 2 :name "Transaction2"}]) | ||
(is (= [{:id 1 :name "Transaction1"} {:id 2 :name "Transaction2"}] (rf/sub [sub-name]))))) | ||
|
||
(h/deftest-sub :wallet/activities-for-current-viewing-account | ||
[sub-name] | ||
(testing "Return activities filtered and grouped by account and dates" | ||
(swap! rf-db/app-db | ||
(fn [db] | ||
(-> db | ||
(assoc-in [:wallet :activities] | ||
[{:sender "acc1" :recipient "acc2" :timestamp 1588291200} | ||
{:sender "acc2" :recipient "acc1" :timestamp 1588377600} | ||
{:sender "acc3" :recipient "acc4" :timestamp 1588464000}]) | ||
(assoc-in [:wallet :current-viewing-account-address] "acc1")))) | ||
(is (= [{:title "May 1, 2020" | ||
:data [{:sender "acc1" :recipient "acc2" :timestamp 1588291200}] | ||
:timestamp 1588291200}] | ||
(rf/sub [sub-name]))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌🏼