Check eligibility status after enabling the share all addresses toggle

This commit is contained in:
Ajay Sivan 2024-02-16 20:39:42 +05:30 committed by Andrea Maria Piana
parent ae75eaeb33
commit ae08cb161f
No known key found for this signature in database
2 changed files with 13 additions and 10 deletions

View File

@ -223,16 +223,19 @@
(defn toggle-share-all-addresses (defn toggle-share-all-addresses
[{:keys [db]} [community-id]] [{:keys [db]} [community-id]]
(let [share-all-addresses? (get-in db [:communities community-id :share-all-addresses?]) (let [share-all-addresses? (get-in db [:communities community-id :share-all-addresses?])
accounts (utils/sorted-non-watch-only-accounts db) next-share-all-addresses? (not share-all-addresses?)
addresses (set (map :address accounts))] accounts (utils/sorted-non-watch-only-accounts db)
addresses (set (map :address accounts))]
{:db (update-in db {:db (update-in db
[:communities community-id] [:communities community-id]
(fn [community] assoc
(-> community :share-all-addresses? next-share-all-addresses?
(assoc :share-all-addresses? (not share-all-addresses?)) :selected-permission-addresses addresses)
(cond-> (not share-all-addresses?) :fx [(when (and community-id next-share-all-addresses?)
(assoc :selected-permission-addresses addresses)))))})) [:dispatch
[:communities/check-permissions-to-join-community community-id
addresses :based-on-client-selection]])]}))
(rf/reg-event-fx :communities/toggle-share-all-addresses (rf/reg-event-fx :communities/toggle-share-all-addresses
toggle-share-all-addresses) toggle-share-all-addresses)

View File

@ -74,8 +74,8 @@
:position 1}}} :position 1}}}
:communities {community-id {:share-all-addresses? true :communities {community-id {:share-all-addresses? true
:previous-share-all-addresses? true :previous-share-all-addresses? true
:previous-permission-addresses #{"0x1"} :previous-permission-addresses #{"0x1" "0x2"}
:selected-permission-addresses #{"0x1"} :selected-permission-addresses #{"0x1" "0x2"}
:airdrop-address "0x1"}}}} :airdrop-address "0x1"}}}}
expected-db (update-in initial-db expected-db (update-in initial-db
[:db :communities community-id] [:db :communities community-id]