Remove support for editing shared addresses while request to join is pending approval (#19623)
This PR completely removes support for editing shared addresses while a user's request to join is pending approval. The reason for the removal is that, in status-go, the control node that will process the message protobuf.ApplicationMetadataMessage_COMMUNITY_EDIT_SHARED_ADDRESSES verifies the user is already a member of the community, but a user waiting for approval to join is not yet a member. Removing this check doesn't sound like a good idea and we want to avoid bugs/complications for the next release. The feature isn't working anyway, so the purpose of this PR is also to cleanup code that doesn't work and won't be re-done anytime soon.
This commit is contained in:
parent
01a503f3bf
commit
54b2e0e678
|
@ -7,10 +7,8 @@
|
|||
|
||||
(defn initialize-permission-addresses
|
||||
[{:keys [db]} [community-id]]
|
||||
(let [{:keys [joined]} (get-in db [:communities community-id])
|
||||
pending-requests (get-in db [:communities/my-pending-requests-to-join community-id])
|
||||
init-using-revealed-accounts? (or joined (seq pending-requests))]
|
||||
{:fx [(if init-using-revealed-accounts?
|
||||
(let [{:keys [joined]} (get-in db [:communities community-id])]
|
||||
{:fx [(if joined
|
||||
[:dispatch
|
||||
[:communities/get-revealed-accounts community-id
|
||||
[:communities/do-init-permission-addresses community-id]]]
|
||||
|
|
|
@ -36,25 +36,15 @@
|
|||
:reveal? false}])
|
||||
|
||||
(deftest initialize-permission-addresses-test
|
||||
(testing "fetches revealed accounts when pending and not joined"
|
||||
(let [cofx {:db {:communities {community-id {:joined false}}
|
||||
:communities/my-pending-requests-to-join {community-id [:anything]}}}]
|
||||
(testing "fetches revealed accounts when joined"
|
||||
(let [cofx {:db {:communities {community-id {:joined true}}}}]
|
||||
(is (match?
|
||||
{:fx [[:dispatch
|
||||
[:communities/get-revealed-accounts community-id
|
||||
[:communities/do-init-permission-addresses community-id]]]]}
|
||||
(sut/initialize-permission-addresses cofx [community-id])))))
|
||||
|
||||
(testing "fetches revealed accounts when not pending and joined"
|
||||
(let [cofx {:db {:communities {community-id {:joined true}}
|
||||
:communities/my-pending-requests-to-join {}}}]
|
||||
(is (match?
|
||||
{:fx [[:dispatch
|
||||
[:communities/get-revealed-accounts community-id
|
||||
[:communities/do-init-permission-addresses community-id]]]]}
|
||||
(sut/initialize-permission-addresses cofx [community-id])))))
|
||||
|
||||
(testing "does not fetch revealed accounts when not pending and not joined"
|
||||
(testing "does not fetch revealed accounts when not joined"
|
||||
(let [cofx {:db {:communities {community-id {:joined false}}
|
||||
:communities/my-pending-requests-to-join {}}}]
|
||||
(is (match?
|
||||
|
|
|
@ -68,7 +68,8 @@
|
|||
[:communities/request-to-join-with-addresses
|
||||
{:community-id id
|
||||
:password password}]))}])
|
||||
(navigate-back)))
|
||||
(navigate-back))
|
||||
[can-edit-addresses?])
|
||||
|
||||
open-permission-sheet
|
||||
(rn/use-callback (fn []
|
||||
|
|
|
@ -40,34 +40,6 @@
|
|||
:token (:symbol balance)
|
||||
:token-img-src (images-by-symbol sym)))))
|
||||
|
||||
(defn- cancel-join-request-drawer
|
||||
[community-id]
|
||||
(let [{:keys [name logo color]} (rf/sub [:communities/for-context-tag community-id])
|
||||
request-id (rf/sub [:communities/my-pending-request-to-join community-id])]
|
||||
[:<>
|
||||
[quo/drawer-top
|
||||
{:type :context-tag
|
||||
:context-tag-type :community
|
||||
:title (i18n/label :t/cancel-request?)
|
||||
:community-name name
|
||||
:community-logo logo
|
||||
:customization-color color}]
|
||||
[rn/view {:style style/drawer-body}
|
||||
[quo/text (i18n/label :t/pending-join-request-farewell)]]
|
||||
[quo/bottom-actions
|
||||
{:actions :two-actions
|
||||
|
||||
:button-one-label (i18n/label :t/confirm-and-cancel)
|
||||
:button-one-props {:customization-color color
|
||||
:on-press
|
||||
(fn []
|
||||
(rf/dispatch [:communities/addresses-for-permissions-cancel-request
|
||||
request-id]))}
|
||||
|
||||
:button-two-label (i18n/label :t/cancel)
|
||||
:button-two-props {:type :grey
|
||||
:on-press #(rf/dispatch [:hide-bottom-sheet])}}]]))
|
||||
|
||||
(defn- confirm-discard-drawer
|
||||
[community-id]
|
||||
(let [{:keys [name logo color]} (rf/sub [:communities/for-context-tag community-id])]
|
||||
|
@ -206,11 +178,6 @@
|
|||
joined (rf/sub [:communities/community-joined id])
|
||||
checking? (rf/sub [:communities/permissions-check-for-selection-checking? id])
|
||||
|
||||
cancel-join-request
|
||||
(rn/use-callback
|
||||
(fn []
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content (fn [] [cancel-join-request-drawer id])}])))
|
||||
leave-community
|
||||
(rn/use-callback
|
||||
(fn []
|
||||
|
@ -237,7 +204,6 @@
|
|||
(rf/dispatch [:hide-bottom-sheet]))}]))}])
|
||||
(rf/dispatch [:communities/set-share-all-addresses id flag-share-all-addresses]))
|
||||
(rf/dispatch [:communities/set-addresses-to-reveal id addresses-to-reveal])))
|
||||
pending? (rf/sub [:communities/has-pending-request-to-join? id])
|
||||
highest-role (rf/sub [:communities/highest-role-for-selection id])
|
||||
[unmodified-role _] (rn/use-state highest-role)]
|
||||
|
||||
|
@ -255,38 +221,20 @@
|
|||
can-edit-addresses?
|
||||
(->
|
||||
(assoc :actions :one-action
|
||||
:button-one-label (cond
|
||||
(and pending? (not highest-role))
|
||||
(i18n/label :t/cancel-request)
|
||||
|
||||
(and joined (not highest-role))
|
||||
:button-one-label (if (and joined (not highest-role))
|
||||
(i18n/label :t/leave-community)
|
||||
|
||||
:else
|
||||
(i18n/label :t/confirm-changes))
|
||||
:description-top-text (cond
|
||||
(and pending? highest-role)
|
||||
(i18n/label :t/eligible-to-join-as)
|
||||
|
||||
(and joined (= highest-role unmodified-role))
|
||||
(i18n/label :t/you-are-a)
|
||||
|
||||
(and joined (not= highest-role unmodified-role))
|
||||
(i18n/label :t/you-will-be-a))
|
||||
:error-message (cond
|
||||
(and pending? (not highest-role))
|
||||
(i18n/label :t/community-join-requirements-not-met)
|
||||
|
||||
(and joined (not highest-role))
|
||||
:error-message (when (and joined (not highest-role))
|
||||
(i18n/label :t/membership-requirements-not-met)))
|
||||
(update :button-one-props
|
||||
merge
|
||||
(cond (and pending? (not highest-role))
|
||||
{:type :danger
|
||||
:disabled? false
|
||||
:on-press cancel-join-request}
|
||||
|
||||
(and joined (not highest-role))
|
||||
(cond (and joined (not highest-role))
|
||||
{:type :danger
|
||||
:disabled? false
|
||||
:on-press leave-community})))
|
||||
|
@ -372,13 +320,8 @@
|
|||
:data wallet-accounts}]
|
||||
|
||||
[selection-bottom-actions id
|
||||
{:flag-share-all-addresses
|
||||
flag-share-all-addresses
|
||||
:addresses-to-reveal
|
||||
addresses-to-reveal
|
||||
:cancel-selection
|
||||
cancel-selection
|
||||
:can-edit-addresses?
|
||||
can-edit-addresses?
|
||||
:identical-choices?
|
||||
identical-choices?}]]))
|
||||
{:flag-share-all-addresses flag-share-all-addresses
|
||||
:addresses-to-reveal addresses-to-reveal
|
||||
:cancel-selection cancel-selection
|
||||
:can-edit-addresses? can-edit-addresses?
|
||||
:identical-choices? identical-choices?}]]))
|
||||
|
|
|
@ -131,25 +131,22 @@
|
|||
request-id])}])})
|
||||
|
||||
(defn not-joined-options
|
||||
[id token-gated? pending? intro-message]
|
||||
[id token-gated? intro-message]
|
||||
[[(when-not token-gated? (view-members id))
|
||||
(when-not token-gated? (view-rules id intro-message))
|
||||
(invite-contacts id)
|
||||
(when token-gated? (view-token-gating id))
|
||||
(when (and pending? (ff/enabled? ::ff/community.edit-account-selection))
|
||||
(edit-shared-addresses id))
|
||||
(show-qr id)
|
||||
(share-community id)]])
|
||||
|
||||
(defn join-request-sent-options
|
||||
[id token-gated? request-id intro-message]
|
||||
[(conj (first (not-joined-options id token-gated? request-id intro-message))
|
||||
[(conj (first (not-joined-options id token-gated? intro-message))
|
||||
(assoc (cancel-request-to-join id request-id) :add-divider? true))])
|
||||
|
||||
(defn banned-options
|
||||
[id token-gated? intro-message]
|
||||
(let [pending? false]
|
||||
(not-joined-options id token-gated? pending? intro-message)))
|
||||
(not-joined-options id token-gated? intro-message))
|
||||
|
||||
(defn joined-options
|
||||
[id token-gated? muted? muted-till color intro-message]
|
||||
|
@ -189,7 +186,7 @@
|
|||
joined (joined-options id role-permissions? muted muted-till color intro-message)
|
||||
request-id (join-request-sent-options id role-permissions? request-id intro-message)
|
||||
banList (banned-options id role-permissions? intro-message)
|
||||
:else (not-joined-options id role-permissions? request-id intro-message))))
|
||||
:else (not-joined-options id role-permissions? intro-message))))
|
||||
|
||||
(defn community-options-bottom-sheet
|
||||
[id]
|
||||
|
|
|
@ -374,9 +374,8 @@
|
|||
(defn get-revealed-accounts
|
||||
[{:keys [db]} [community-id on-success]]
|
||||
(let [{:keys [joined fetching-revealed-accounts]
|
||||
:as community} (get-in db [:communities community-id])
|
||||
pending? (get-in db [:communities/my-pending-requests-to-join community-id])]
|
||||
(when (and community (or pending? joined) (not fetching-revealed-accounts))
|
||||
:as community} (get-in db [:communities community-id])]
|
||||
(when (and community joined (not fetching-revealed-accounts))
|
||||
{:db (assoc-in db [:communities community-id :fetching-revealed-accounts] true)
|
||||
:json-rpc/call
|
||||
[{:method "wakuext_getRevealedAccounts"
|
||||
|
|
|
@ -167,26 +167,7 @@
|
|||
(:db effects)))
|
||||
(is (match? {:method "wakuext_getRevealedAccounts"
|
||||
:params [community-id "profile-public-key"]}
|
||||
(-> effects :json-rpc/call first (select-keys [:method :params]))))))
|
||||
|
||||
(testing "given there is a pending request"
|
||||
(let [pub-key "profile-public-key"
|
||||
community (assoc community :joined false)
|
||||
db {:communities {community-id community}
|
||||
:profile/profile {:public-key pub-key}
|
||||
:communities/my-pending-requests-to-join {community-id [:anything]}}
|
||||
on-success [:some-event-id]
|
||||
actual (events/get-revealed-accounts {:db db} [community-id on-success])
|
||||
expected {:db (assoc-in db
|
||||
[:communities community-id :fetching-revealed-accounts]
|
||||
true)
|
||||
:json-rpc/call [{:method "wakuext_getRevealedAccounts"
|
||||
:params [community-id pub-key]
|
||||
:js-response true
|
||||
:on-success [:communities/get-revealed-accounts-success
|
||||
community-id on-success]
|
||||
:on-error fn?}]}]
|
||||
(is (match? expected actual))))))
|
||||
(-> effects :json-rpc/call first (select-keys [:method :params]))))))))
|
||||
|
||||
(deftest handle-community
|
||||
(let [community {:id community-id :clock 2}]
|
||||
|
|
|
@ -30,18 +30,16 @@
|
|||
|
||||
(re-frame/reg-sub :communities/can-edit-shared-addresses?
|
||||
(fn [[_ community-id]]
|
||||
[(re-frame/subscribe [:communities/community community-id])
|
||||
(re-frame/subscribe [:communities/my-pending-request-to-join community-id])])
|
||||
(fn [[{:keys [joined]} pending-requests]]
|
||||
(boolean (or joined (seq pending-requests)))))
|
||||
(re-frame/subscribe [:communities/community community-id]))
|
||||
(fn [{:keys [joined]}]
|
||||
joined))
|
||||
|
||||
(re-frame/reg-sub :communities/permissions-check-for-selection
|
||||
:<- [:communities/permissions-checks-for-selection]
|
||||
(fn [permissions [_ id]]
|
||||
(get permissions id)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:communities/permissions-check-for-selection-checking?
|
||||
(re-frame/reg-sub :communities/permissions-check-for-selection-checking?
|
||||
(fn [[_ community-id]]
|
||||
(re-frame/subscribe [:communities/permissions-check-for-selection community-id]))
|
||||
(fn [check]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.subs.community.account-selection-test
|
||||
(:require
|
||||
[cljs.test :refer [is testing]]
|
||||
[cljs.test :refer [is]]
|
||||
matcher-combinators.test
|
||||
[re-frame.db :as rf-db]
|
||||
status-im.subs.communities
|
||||
|
@ -22,36 +22,6 @@
|
|||
:color :orange}
|
||||
(rf/sub [sub-name community-id]))))
|
||||
|
||||
(h/deftest-sub :communities/can-edit-shared-addresses?
|
||||
[sub-name]
|
||||
(testing "joined community and there are pending requests"
|
||||
(reset! rf-db/app-db
|
||||
{:communities {community-id {:id community-id :joined true}}
|
||||
:communities/my-pending-request-to-join {community-id {:id :request-id-1}}})
|
||||
|
||||
(is (true? (rf/sub [sub-name community-id]))))
|
||||
|
||||
(testing "joined community and there are no pending requests"
|
||||
(reset! rf-db/app-db
|
||||
{:communities {community-id {:id community-id :joined true}}
|
||||
:communities/my-pending-request-to-join {community-id {}}})
|
||||
|
||||
(is (true? (rf/sub [sub-name community-id]))))
|
||||
|
||||
(testing "not joined community and there are pending requests"
|
||||
(reset! rf-db/app-db
|
||||
{:communities {community-id {:id community-id :joined false}}
|
||||
:communities/my-pending-request-to-join {community-id {:id :request-id-1}}})
|
||||
|
||||
(is (false? (rf/sub [sub-name community-id]))))
|
||||
|
||||
(testing "not joined community and there are no pending requests"
|
||||
(reset! rf-db/app-db
|
||||
{:communities {community-id {:id community-id :joined false}}
|
||||
:communities/my-pending-request-to-join {community-id {}}})
|
||||
|
||||
(is (false? (rf/sub [sub-name community-id])))))
|
||||
|
||||
(h/deftest-sub :communities/airdrop-account
|
||||
[sub-name]
|
||||
(let [airdrop-account {:address "0xA" :position 1}]
|
||||
|
|
|
@ -2287,12 +2287,9 @@
|
|||
"membership-requirements-not-met": "Membership requirements not met",
|
||||
"edit-shared-addresses": "Edit shared addresses",
|
||||
"leave-community-farewell": "We’ll be sad to see you go but remember, you can come back at any time! All shared addresses will be unshared.",
|
||||
"pending-join-request-farewell": "We’ll be sad to see you go but remember, you can request to join this community at any point. All shared addresses will be unshared.",
|
||||
"all-changes-will-be-discarded": "All changes in shared addresses for permissions will be discarded.",
|
||||
"cancel-request": "Cancel request",
|
||||
"discard": "Discard",
|
||||
"discard-changes?": "Discard changes?",
|
||||
"confirm-and-cancel": "Confirm and cancel",
|
||||
"you-will-be-a": "You’ll be a",
|
||||
"you-are-a": "You’re a",
|
||||
"you-are-a-role": "You’re a {{role}}",
|
||||
|
|
Loading…
Reference in New Issue