From 9a6fa2c2aba5ce5c50c042ea1b361a1576dbb4d8 Mon Sep 17 00:00:00 2001 From: Ulises M Date: Thu, 13 Jun 2024 14:09:37 -0600 Subject: [PATCH] feat(wallet): Remove non operable accounts from account switcher --- .../wallet/sheets/account_options/view.cljs | 5 +++-- .../wallet/sheets/select_account/view.cljs | 2 +- src/status_im/subs/wallet/wallet.cljs | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/status_im/contexts/wallet/sheets/account_options/view.cljs b/src/status_im/contexts/wallet/sheets/account_options/view.cljs index 981224cb5d..248f180a46 100644 --- a/src/status_im/contexts/wallet/sheets/account_options/view.cljs +++ b/src/status_im/contexts/wallet/sheets/account_options/view.cljs @@ -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? diff --git a/src/status_im/contexts/wallet/sheets/select_account/view.cljs b/src/status_im/contexts/wallet/sheets/select_account/view.cljs index 5a3df1d0f0..3e79abe671 100644 --- a/src/status_im/contexts/wallet/sheets/select_account/view.cljs +++ b/src/status_im/contexts/wallet/sheets/select_account/view.cljs @@ -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 diff --git a/src/status_im/subs/wallet/wallet.cljs b/src/status_im/subs/wallet/wallet.cljs index 69561b9992..56c696255a 100644 --- a/src/status_im/subs/wallet/wallet.cljs +++ b/src/status_im/subs/wallet/wallet.cljs @@ -422,6 +422,22 @@ (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]