feat(wallet): add recent recipients tab (#19942)
This commit is contained in:
parent
d658fcf3db
commit
e72e25c342
|
@ -33,7 +33,7 @@
|
|||
[options-drawer/view
|
||||
{:name (:name collectible-details)
|
||||
:image (:uri preview-url)}])}]))}]
|
||||
:activity [activity/view {:activities []}]
|
||||
:activity [activity/view]
|
||||
:permissions [empty-tab/view
|
||||
{:title (i18n/label :t/no-permissions)
|
||||
:description (i18n/label :t/no-collectibles-description)
|
||||
|
|
|
@ -64,9 +64,6 @@
|
|||
:default-active @selected-tab
|
||||
:data (tabs-data watch-only?)
|
||||
:on-change (rn/use-callback (fn [tab]
|
||||
(when (and (= :activity tab)
|
||||
(ff/enabled? :FLAG_WALLET_ACTIVITY_ENABLED))
|
||||
(rf/dispatch [:wallet/fetch-activities]))
|
||||
(reset! selected-tab tab)))
|
||||
:scrollable? true
|
||||
:scroll-on-press? true}]
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
[status-im.common.resources :as status.resources]
|
||||
[utils.i18n :as i18n]))
|
||||
|
||||
(def address "0x39cf6E0Ba4C4530735616e1Ee7ff5FbCB726fBd4")
|
||||
|
||||
(def buy-tokens-list
|
||||
[{:title "Ramp"
|
||||
:description :text
|
||||
|
|
|
@ -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]]]}))
|
||||
|
||||
(rf/reg-event-fx :wallet/navigate-to-new-account
|
||||
(fn [{:keys [db]} [address]]
|
||||
|
|
|
@ -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))
|
||||
|
@ -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))
|
||||
[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
|
||||
{: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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)))))
|
||||
|
|
|
@ -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])))))
|
||||
|
|
Loading…
Reference in New Issue