feat(wallet): Remove non-operable accounts from account switcher (#20457)

* feat(wallet): Remove non-operable accounts from account switcher

* Remove non-operable accounts in the From page
This commit is contained in:
Ulises Manuel 2024-06-20 17:14:26 -06:00 committed by GitHub
parent fbc9b59a5e
commit 1e703cdc81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 32 additions and 14 deletions

View File

@ -210,12 +210,10 @@
:always (assoc-in [:wallet :ui :send :token-display-name]
(:symbol token))
:always (assoc-in
[:wallet :ui :send
:token-not-supported-in-receiver-networks?]
[:wallet :ui :send :token-not-supported-in-receiver-networks?]
token-not-supported-in-receiver-networks?)
token (assoc-in [:wallet :ui :send :token] token)
token-symbol (assoc-in [:wallet :ui :send :token-symbol]
token-symbol))
token-symbol (assoc-in [:wallet :ui :send :token-symbol] token-symbol))
:fx [[:dispatch [:wallet/clean-suggested-routes]]
[:dispatch
[:wallet/wizard-navigate-forward
@ -253,8 +251,7 @@
:collectible
:token-display-name
:amount
(when (send-utils/tx-type-collectible?
transaction-type)
(when (send-utils/tx-type-collectible? transaction-type)
:tx-type))})))
(rf/reg-event-fx

View File

@ -108,8 +108,9 @@
[]
(let [options-height (reagent/atom 0)]
(fn []
(let [theme (quo.theme/use-theme)
accounts (rf/sub [:wallet/accounts-without-current-viewing-account])
(let [theme (quo.theme/use-theme)
accounts (rf/sub
[:wallet/fully-or-partially-operable-accounts-without-current-viewing-account])
show-account-selector? (pos? (count accounts))]
[:<>
(when show-account-selector?

View File

@ -20,7 +20,7 @@
(defn view
[]
(let [selected-account-address (rf/sub [:wallet/current-viewing-account-address])
accounts (rf/sub [:wallet/accounts-without-watched-accounts])]
accounts (rf/sub [:wallet/fully-or-partially-operable-accounts-without-watched-accounts])]
[:<>
[quo/drawer-top {:title (i18n/label :t/select-account)}]
[gesture/flat-list

View File

@ -446,9 +446,25 @@
(fn [accounts]
(remove :watch-only? accounts)))
(defn- keep-fully-or-partially-operable-accounts
[accounts]
(filter (fn fully-or-partially-operable? [{:keys [operable]}]
(#{:fully :partially} operable))
accounts))
(rf/reg-sub
:wallet/fully-or-partially-operable-accounts-without-current-viewing-account
:<- [:wallet/accounts-without-current-viewing-account]
keep-fully-or-partially-operable-accounts)
(rf/reg-sub
:wallet/fully-or-partially-operable-accounts-without-watched-accounts
:<- [:wallet/accounts-without-watched-accounts]
keep-fully-or-partially-operable-accounts)
(rf/reg-sub
:wallet/accounts-with-current-asset
:<- [:wallet/accounts-without-watched-accounts]
:<- [:wallet/fully-or-partially-operable-accounts-without-watched-accounts]
:<- [:wallet/wallet-send-token-symbol]
:<- [:wallet/wallet-send-token]
(fn [[accounts token-symbol token]]

View File

@ -15,10 +15,12 @@
(def ^:private accounts-with-tokens
{:0x1 {:tokens [{:symbol "ETH"} {:symbol "SNT"}]
:network-preferences-names #{}
:customization-color nil}
:customization-color nil
:operable :fully}
:0x2 {:tokens [{:symbol "SNT"}]
:network-preferences-names #{}
:customization-color nil}})
:customization-color nil
:operable :partially}})
(def tokens-0x1
[{:decimals 1
@ -481,7 +483,8 @@
(is (match? result
[{:tokens [{:symbol "ETH"} {:symbol "SNT"}]
:network-preferences-names #{}
:customization-color nil}]))))
:customization-color nil
:operable :fully}]))))
(testing "returns the accounts list with the current asset using token"
(swap! rf-db/app-db
@ -492,7 +495,8 @@
(is (match? result
[{:tokens [{:symbol "ETH"} {:symbol "SNT"}]
:network-preferences-names #{}
:customization-color nil}]))))
:customization-color nil
:operable :fully}]))))
(testing
"returns the full accounts list with the current asset using token-symbol if each account has the asset"