Skip to content

Commit cefc3ec

Browse files
[#22318] fix: re-enabled watched accounts with limited number (#22390)
* [#22318] fix: re-enabled watched accounts with limited number * [#22397] fix: display remove account button for watch only account * [#22318] feat: display toast message when reached limit * [#22318] fix: set max account to 20 * [#22390] fix: hide activity tab and filter out watch only account * [#22411] fix: network drawer operable account balance
1 parent 349eee4 commit cefc3ec

File tree

8 files changed

+42
-20
lines changed

8 files changed

+42
-20
lines changed

src/status_im/constants.cljs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,5 @@
489489
(def ^:const status-mobile-url "https://github.com/status-im/status-mobile")
490490

491491
(def ^:const wc-connection-string-identifier "wc")
492+
493+
(def ^:const max-allowed-watched-accounts 20)

src/status_im/contexts/wallet/account/view.cljs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515

1616
;; NOTE: If the id of the tabs are changed, please check 'wallet/select-account-tab' event as
1717
;; a activity event depends on it
18-
(def tabs-data
18+
(defn tabs-data
19+
[watch-only?]
1920
[{:id :assets :label (i18n/label :t/assets) :accessibility-label :assets-tab}
2021
{:id :collectibles :label (i18n/label :t/collectibles) :accessibility-label :collectibles-tab}
21-
{:id :activity :label (i18n/label :t/activity) :accessibility-label :activity-tab}
22+
(when-not watch-only?
23+
{:id :activity :label (i18n/label :t/activity) :accessibility-label :activity-tab})
2224
{:id :about :label (i18n/label :t/about) :accessibility-label :about}])
2325

2426
(defn- change-tab [id] (rf/dispatch [:wallet/select-account-tab id]))
@@ -69,7 +71,7 @@
6971
{:style style/tabs
7072
:size 32
7173
:active-tab-id selected-tab
72-
:data tabs-data
74+
:data (tabs-data watch-only?)
7375
:on-change change-tab
7476
:scrollable? true
7577
:scroll-on-press? true}]

src/status_im/contexts/wallet/data_store.cljs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525

2626
(defn add-keys-to-account
2727
[account]
28-
(-> account
29-
(assoc :operable? (not= (:operable account) :no))
30-
(assoc :watch-only? (= (:type account) :watch))
31-
(assoc :default-account? (:wallet account))))
28+
(let [watch-only? (= (:type account) :watch)]
29+
(-> account
30+
(assoc :operable? (and (not= (:operable account) :no) (not watch-only?)))
31+
(assoc :watch-only? watch-only?)
32+
(assoc :default-account? (:wallet account)))))
3233

3334
(defn- sanitize-emoji
3435
"As Desktop uses Twemoji, the emoji received can be an img tag

src/status_im/contexts/wallet/home/view.cljs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[react-native.core :as rn]
77
[status-im.common.home.top-nav.view :as common.top-nav]
88
[status-im.common.refreshable-flat-list.view :as refreshable-flat-list]
9+
[status-im.constants :as constants]
910
[status-im.contexts.wallet.home.style :as style]
1011
[status-im.contexts.wallet.home.tabs.view :as tabs]
1112
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
@@ -16,19 +17,33 @@
1617

1718
(defn new-account
1819
[]
19-
[quo/action-drawer
20-
[[{:icon :i/add
21-
:accessibility-label :start-a-new-chat
22-
:label (i18n/label :t/add-account)
23-
:sub-label (i18n/label :t/add-account-description)
24-
:on-press #(rf/dispatch [:navigate-to :screen/wallet.create-account])}
25-
(when (ff/enabled? ::ff/wallet.add-watched-address)
20+
(let [watched-accounts (rf/sub [:wallet/watch-only-accounts])
21+
reached-max-watched-account? (>= (count watched-accounts)
22+
constants/max-allowed-watched-accounts)
23+
on-add-address-press (rn/use-callback
24+
(fn []
25+
(if reached-max-watched-account?
26+
(rf/dispatch [:toasts/upsert
27+
{:type :negative
28+
:theme :dark
29+
:text
30+
(i18n/label
31+
:t/saved-addresses-limit-reached-toast)}])
32+
(rf/dispatch [:navigate-to
33+
:screen/wallet.add-address-to-watch])))
34+
[reached-max-watched-account?])]
35+
[quo/action-drawer
36+
[[{:icon :i/add
37+
:accessibility-label :start-a-new-chat
38+
:label (i18n/label :t/add-account)
39+
:sub-label (i18n/label :t/add-account-description)
40+
:on-press #(rf/dispatch [:navigate-to :screen/wallet.create-account])}
2641
{:icon :i/reveal
2742
:accessibility-label :add-a-contact
2843
:label (i18n/label :t/add-address-to-watch)
2944
:sub-label (i18n/label :t/add-address-to-watch-description)
30-
:on-press #(rf/dispatch [:navigate-to :screen/wallet.add-address-to-watch])
31-
:add-divider? true})]]])
45+
:on-press on-add-address-press
46+
:add-divider? true}]]]))
3247

3348
(defn- new-account-card-data
3449
[]

src/status_im/contexts/wallet/sheets/account_options/view.cljs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
(let [{:keys [name color emoji address watch-only?
3535
default-account?]} (rf/sub [:wallet/current-viewing-account])
3636
{:keys [derived-from]} (rf/sub [:wallet/current-viewing-account-keypair])
37-
share-title (i18n/label :t/share-address-title {:address name})]
37+
share-title (i18n/label :t/share-address-title {:address name})
38+
deletable? (or watch-only?
39+
(not (or default-account? (string/blank? derived-from))))]
3840
[rn/view
3941
{:on-layout #(reset! options-height (oops/oget % "nativeEvent.layout.height"))
4042
:style (when show-account-selector? style/options-container)}
@@ -85,7 +87,7 @@
8587
#(rf/dispatch [:wallet/share-account
8688
{:title share-title :content address}])
8789
600))}
88-
(when-not (or default-account? (string/blank? derived-from))
90+
(when deletable?
8991
{:add-divider? (not show-account-selector?)
9092
:icon :i/delete
9193
:accessibility-label :remove-account

src/status_im/feature_flags.cljs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
;; works and we may re-enable it by default.
2121
::profile-pictures-visibility (enabled-in-env? :FLAG_PROFILE_PICTURES_VISIBILITY_ENABLED)
2222
::settings.import-all-keypairs (enabled-in-env? :FLAG_WALLET_SETTINGS_IMPORT_ALL_KEYPAIRS)
23-
::wallet.add-watched-address (enabled-in-env? :FLAG_ADD_WATCHED_ADDRESS)
2423
::wallet.advanced-sending (enabled-in-env? :FLAG_ADVANCED_SENDING)
2524
::wallet.assets-modal-hide (enabled-in-env? :FLAG_ASSETS_MODAL_HIDE)
2625
::wallet.assets-modal-manage-tokens (enabled-in-env? :FLAG_ASSETS_MODAL_MANAGE_TOKENS)

src/status_im/subs/wallet/wallet.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@
580580

581581
(rf/reg-sub
582582
:wallet/token-by-symbol-from-first-available-account-with-balance
583-
:<- [:wallet/accounts]
583+
:<- [:wallet/operable-accounts]
584584
:<- [:wallet/current-viewing-account-or-default]
585585
:<- [:wallet/network-details]
586586
(fn [[accounts {:keys [tokens]} networks] [_ token-symbol chain-ids]]

translations/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,6 +2950,7 @@
29502950
"watch-only": "Watch-only",
29512951
"watched-account-removed": "Watched address has been removed",
29522952
"watched-address": "Watched address",
2953+
"watched-addresses-limit-reached-toast": "Limit of 20 watched addresses reached: remove a watched address to add a new one.",
29532954
"ways-to-buy": "Ways to buy",
29542955
"ways-to-buy-assets": "Ways to buy assets",
29552956
"wc-brand-guide": "Guidance on using branding such as trademarks and logos",

0 commit comments

Comments
 (0)