Skip to content

Commit

Permalink
Check eligibility status after enabling the share all addresses toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayesivan committed Feb 16, 2024
1 parent b27f323 commit 67b7d87
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/status_im/contexts/communities/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,20 @@

(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?)
(assoc :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)
Expand Down

0 comments on commit 67b7d87

Please sign in to comment.