From ae08cb161f0d7d8609379ae3c31f117cf16d1a4d Mon Sep 17 00:00:00 2001 From: Ajay Sivan Date: Fri, 16 Feb 2024 20:39:42 +0530 Subject: [PATCH] Check eligibility status after enabling the share all addresses toggle --- .../contexts/communities/events.cljs | 19 +++++++++++-------- .../contexts/communities/events_test.cljs | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/status_im/contexts/communities/events.cljs b/src/status_im/contexts/communities/events.cljs index 36777deee6..b04be2b56e 100644 --- a/src/status_im/contexts/communities/events.cljs +++ b/src/status_im/contexts/communities/events.cljs @@ -223,16 +223,19 @@ (defn toggle-share-all-addresses [{:keys [db]} [community-id]] - (let [share-all-addresses? (get-in db [:communities community-id :share-all-addresses?]) - accounts (utils/sorted-non-watch-only-accounts db) - addresses (set (map :address accounts))] + (let [share-all-addresses? (get-in db [:communities community-id :share-all-addresses?]) + next-share-all-addresses? (not share-all-addresses?) + accounts (utils/sorted-non-watch-only-accounts db) + addresses (set (map :address accounts))] {:db (update-in db [:communities community-id] - (fn [community] - (-> community - (assoc :share-all-addresses? (not share-all-addresses?)) - (cond-> (not share-all-addresses?) - (assoc :selected-permission-addresses addresses)))))})) + assoc + :share-all-addresses? next-share-all-addresses? + :selected-permission-addresses addresses) + :fx [(when (and community-id next-share-all-addresses?) + [:dispatch + [:communities/check-permissions-to-join-community community-id + addresses :based-on-client-selection]])]})) (rf/reg-event-fx :communities/toggle-share-all-addresses toggle-share-all-addresses) diff --git a/src/status_im/contexts/communities/events_test.cljs b/src/status_im/contexts/communities/events_test.cljs index 374d8763bb..25dffdc49b 100644 --- a/src/status_im/contexts/communities/events_test.cljs +++ b/src/status_im/contexts/communities/events_test.cljs @@ -74,8 +74,8 @@ :position 1}}} :communities {community-id {:share-all-addresses? true :previous-share-all-addresses? true - :previous-permission-addresses #{"0x1"} - :selected-permission-addresses #{"0x1"} + :previous-permission-addresses #{"0x1" "0x2"} + :selected-permission-addresses #{"0x1" "0x2"} :airdrop-address "0x1"}}}} expected-db (update-in initial-db [:db :communities community-id]