Skip to content
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

feat(wallet): add recent recipients tab #19942

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/status_im/contexts/wallet/account/tabs/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
[options-drawer/view
{:name (:name collectible-details)
:image (:uri preview-url)}])}]))}]
:activity [activity/view {:activities []}]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

:activity [activity/view]
:permissions [empty-tab/view
{:title (i18n/label :t/no-permissions)
:description (i18n/label :t/no-collectibles-description)
Expand Down
3 changes: 0 additions & 3 deletions src/status_im/contexts/wallet/account/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@
:default-active @selected-tab
:data (tabs-data watch-only?)
:on-change (rn/use-callback (fn [tab]
(when (and (= :activity tab)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to account page transition

(ff/enabled? :FLAG_WALLET_ACTIVITY_ENABLED))
(rf/dispatch [:wallet/fetch-activities]))
(reset! selected-tab tab)))
:scrollable? true
:scroll-on-press? true}]
Expand Down
2 changes: 0 additions & 2 deletions src/status_im/contexts/wallet/common/temp.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
[status-im.common.resources :as status.resources]
[utils.i18n :as i18n]))

(def address "0x39cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd4")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused


(def buy-tokens-list
[{:title "Ramp"
:description :text
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/contexts/wallet/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
(rf/reg-event-fx :wallet/navigate-to-account
(fn [{:keys [db]} [address]]
{:db (assoc-in db [:wallet :current-viewing-account-address] address)
:fx [[:dispatch [:navigate-to :screen/wallet.accounts address]]]}))
:fx [[:dispatch [:navigate-to :screen/wallet.accounts address]]
[:dispatch [:wallet/fetch-activities]]]}))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch activities here


(rf/reg-event-fx :wallet/navigate-to-new-account
(fn [{:keys [db]} [address]]
Expand Down
27 changes: 21 additions & 6 deletions src/status_im/contexts/wallet/send/select_address/tabs/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

(defn my-accounts
(defn- my-accounts
[theme]
(let [other-accounts (rf/sub [:wallet/accounts-without-current-viewing-account])]
(if (zero? (count other-accounts))
Expand All @@ -27,15 +27,30 @@
:stack-id :screen/wallet.select-address}])}]))
other-accounts))))

(defn- recent-transactions
[theme]
(let [recent-recipients (rf/sub [:wallet/recent-recipients])]
(if (zero? (count recent-recipients))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be (empty? recent-recipients) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the suggestion, will update this.

[quo/empty-state
{:title (i18n/label :t/no-recent-transactions)
:description (i18n/label :t/make-one-it-is-easy-we-promise)
:image (resources/get-themed-image :angry-man theme)
:container-style style/empty-container-style}]
(into [rn/view {:style style/my-accounts-container}]
(map (fn [address]
[quo/address
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eventually this will use accounts and saved address etc too 👍

{:address address
:on-press #(rf/dispatch [:wallet/select-send-address
{:address address
:recipient address
:stack-id :screen/wallet.select-address}])}]))
recent-recipients))))

(defn view
[{:keys [selected-tab]}]
(let [theme (quo.theme/use-theme)]
(case selected-tab
:tab/recent [quo/empty-state
{:title (i18n/label :t/no-recent-transactions)
:description (i18n/label :t/make-one-it-is-easy-we-promise)
:image (resources/get-themed-image :angry-man theme)
:container-style style/empty-container-style}]
:tab/recent [recent-transactions theme]
:tab/saved [quo/empty-state
{:title (i18n/label :t/no-saved-addresses)
:description (i18n/label :t/you-like-to-type-43-characters)
Expand Down
1 change: 0 additions & 1 deletion src/status_im/feature_flags.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
::settings.wallet-settings (enabled-in-env? :FLAG_WALLET_SETTINGS_ENABLED)
::settings.keypairs-and-accounts (enabled-in-env?
:FLAG_WALLET_SETTINGS_KEYPAIRS_AND_ACCOUNTS_ENABLED)
::wallet.activities (enabled-in-env? :FLAG_WALLET_ACTIVITY_ENABLED)
::wallet.assets-modal-hide (enabled-in-env? :FLAG_ASSETS_MODAL_HIDE)
::wallet.assets-modal-manage-tokens (enabled-in-env? :FLAG_ASSETS_MODAL_MANAGE_TOKENS)
::wallet.bridge-token (enabled-in-env? :FLAG_BRIDGE_TOKEN_ENABLED)
Expand Down
10 changes: 10 additions & 0 deletions src/status_im/subs/wallet/send.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,13 @@
(let [send-tx-ids (set (keys transactions))]
(select-keys transactions
(filter send-tx-ids tx-ids)))))

(rf/reg-sub
:wallet/recent-recipients
:<- [:wallet/activities-for-current-viewing-account]
:<- [:wallet/current-viewing-account-address]
(fn [[activities current-viewing-account-address]]
(let [users-sent-transactions (filter (fn [{:keys [sender]}]
(= sender current-viewing-account-address))
activities)]
(set (map :recipient users-sent-transactions)))))
13 changes: 13 additions & 0 deletions src/status_im/subs/wallet/send_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,16 @@
:id 100
:chain-id 5}}
(rf/sub [sub-name])))))

(h/deftest-sub :wallet/recent-recipients
[sub-name]
(testing "returns recent tab for selecting address"
(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 (= #{"acc2"} (rf/sub [sub-name])))))