Show token requirements only for token gated channels (#19529)
* fix: use role-permissions? instead of token-permission token-permissions contains channel-permissions as well, which don't make the community token-gated Signed-off-by: Cristian Lungu <lungucristian95@gmail.com> * fix: hide token requirements from open channels Signed-off-by: Cristian Lungu <lungucristian95@gmail.com> * fixed tests Signed-off-by: Cristian Lungu <lungucristian95@gmail.com> --------- Signed-off-by: Cristian Lungu <lungucristian95@gmail.com>
This commit is contained in:
parent
b5962fd83a
commit
c875fb33fa
|
@ -112,12 +112,14 @@
|
||||||
|
|
||||||
(defn actions
|
(defn actions
|
||||||
[{:keys [locked? chat-id community-id]} inside-chat? hide-view-members?]
|
[{:keys [locked? chat-id community-id]} inside-chat? hide-view-members?]
|
||||||
(let [{:keys [muted muted-till chat-type]} (rf/sub [:chats/chat-by-id chat-id])]
|
(let [{:keys [muted muted-till chat-type]} (rf/sub [:chats/chat-by-id chat-id])
|
||||||
|
{:keys [token-gated?]} (rf/sub [:chats/community-chat-by-id community-id chat-id])]
|
||||||
(cond
|
(cond
|
||||||
locked?
|
locked?
|
||||||
[quo/action-drawer
|
[quo/action-drawer
|
||||||
[[(action-invite-people)
|
[[(action-invite-people)
|
||||||
(action-token-requirements)
|
(when token-gated?
|
||||||
|
(action-token-requirements))
|
||||||
(action-qr-code chat-id)
|
(action-qr-code chat-id)
|
||||||
(action-share chat-id)]]]
|
(action-share chat-id)]]]
|
||||||
|
|
||||||
|
@ -135,7 +137,8 @@
|
||||||
(and inside-chat? (not locked?))
|
(and inside-chat? (not locked?))
|
||||||
[quo/action-drawer
|
[quo/action-drawer
|
||||||
[[(action-view-members-and-details community-id chat-id)
|
[[(action-view-members-and-details community-id chat-id)
|
||||||
(action-token-requirements)
|
(when token-gated?
|
||||||
|
(action-token-requirements))
|
||||||
(action-mark-as-read)
|
(action-mark-as-read)
|
||||||
(action-toggle-muted chat-id muted muted-till chat-type)
|
(action-toggle-muted chat-id muted muted-till chat-type)
|
||||||
(action-notification-settings)
|
(action-notification-settings)
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
(h/test "joined options - Token Gated"
|
(h/test "joined options - Token Gated"
|
||||||
(h/setup-subs {:communities/my-pending-request-to-join nil
|
(h/setup-subs {:communities/my-pending-request-to-join nil
|
||||||
:communities/community {:joined true
|
:communities/community {:joined true
|
||||||
:token-permissions []}})
|
:role-permissions? true}})
|
||||||
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
||||||
(h/is-truthy (h/get-by-translation-text :t/view-members))
|
(h/is-truthy (h/get-by-translation-text :t/view-members))
|
||||||
(h/is-truthy (h/get-by-translation-text :t/view-community-rules))
|
(h/is-truthy (h/get-by-translation-text :t/view-community-rules))
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
(h/test "admin options - Token Gated"
|
(h/test "admin options - Token Gated"
|
||||||
(h/setup-subs {:communities/my-pending-request-to-join nil
|
(h/setup-subs {:communities/my-pending-request-to-join nil
|
||||||
:communities/community {:admin true
|
:communities/community {:admin true
|
||||||
:token-permissions []}})
|
:role-permissions? true}})
|
||||||
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
||||||
(h/is-truthy (h/get-by-translation-text :t/view-members))
|
(h/is-truthy (h/get-by-translation-text :t/view-members))
|
||||||
(h/is-truthy (h/get-by-translation-text :t/view-community-rules))
|
(h/is-truthy (h/get-by-translation-text :t/view-community-rules))
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
|
|
||||||
(h/test "request sent options - Token Gated"
|
(h/test "request sent options - Token Gated"
|
||||||
(h/setup-subs {:communities/my-pending-request-to-join "mock-id"
|
(h/setup-subs {:communities/my-pending-request-to-join "mock-id"
|
||||||
:communities/community {:token-permissions []}})
|
:communities/community {:role-permissions? true}})
|
||||||
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
||||||
(h/is-truthy (h/get-by-translation-text :t/invite-people-from-contacts))
|
(h/is-truthy (h/get-by-translation-text :t/invite-people-from-contacts))
|
||||||
(h/is-truthy (h/get-by-translation-text :t/view-token-gating))
|
(h/is-truthy (h/get-by-translation-text :t/view-token-gating))
|
||||||
|
@ -97,7 +97,7 @@
|
||||||
(h/test "banned options - Token Gated"
|
(h/test "banned options - Token Gated"
|
||||||
(h/setup-subs {:communities/my-pending-request-to-join nil
|
(h/setup-subs {:communities/my-pending-request-to-join nil
|
||||||
:communities/community {:banList 100
|
:communities/community {:banList 100
|
||||||
:token-permissions []}})
|
:role-permissions? true}})
|
||||||
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
||||||
(h/is-truthy (h/get-by-translation-text :t/invite-people-from-contacts))
|
(h/is-truthy (h/get-by-translation-text :t/invite-people-from-contacts))
|
||||||
(h/is-truthy (h/get-by-translation-text :t/view-token-gating))
|
(h/is-truthy (h/get-by-translation-text :t/view-token-gating))
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
(h/test "banned options - Token Gated"
|
(h/test "banned options - Token Gated"
|
||||||
(h/setup-subs {:communities/my-pending-request-to-join nil
|
(h/setup-subs {:communities/my-pending-request-to-join nil
|
||||||
:communities/community {:banList 100
|
:communities/community {:banList 100
|
||||||
:token-permissions []}})
|
:role-permissions? true}})
|
||||||
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
||||||
(h/is-truthy (h/get-by-translation-text :t/invite-people-from-contacts))
|
(h/is-truthy (h/get-by-translation-text :t/invite-people-from-contacts))
|
||||||
(h/is-truthy (h/get-by-translation-text :t/view-token-gating))
|
(h/is-truthy (h/get-by-translation-text :t/view-token-gating))
|
||||||
|
@ -118,6 +118,6 @@
|
||||||
(h/setup-subs {:communities/my-pending-request-to-join nil
|
(h/setup-subs {:communities/my-pending-request-to-join nil
|
||||||
:communities/community {:joined true
|
:communities/community {:joined true
|
||||||
:muted true
|
:muted true
|
||||||
:token-permissions []}})
|
:role-permissions? true}})
|
||||||
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
(h/render [options/community-options-bottom-sheet {:id "test"}])
|
||||||
(h/is-truthy (h/get-by-translation-text :t/unmute-community))))
|
(h/is-truthy (h/get-by-translation-text :t/unmute-community))))
|
||||||
|
|
|
@ -180,16 +180,16 @@
|
||||||
|
|
||||||
(defn get-context-drawers
|
(defn get-context-drawers
|
||||||
[{:keys [id]}]
|
[{:keys [id]}]
|
||||||
(let [{:keys [token-permissions admin joined
|
(let [{:keys [role-permissions? admin joined
|
||||||
muted banList muted-till color
|
muted banList muted-till color
|
||||||
intro-message]} (rf/sub [:communities/community id])
|
intro-message]} (rf/sub [:communities/community id])
|
||||||
request-id (rf/sub [:communities/my-pending-request-to-join id])]
|
request-id (rf/sub [:communities/my-pending-request-to-join id])]
|
||||||
(cond
|
(cond
|
||||||
admin (owner-options id token-permissions muted muted-till intro-message)
|
admin (owner-options id role-permissions? muted muted-till intro-message)
|
||||||
joined (joined-options id token-permissions muted muted-till color intro-message)
|
joined (joined-options id role-permissions? muted muted-till color intro-message)
|
||||||
request-id (join-request-sent-options id token-permissions request-id intro-message)
|
request-id (join-request-sent-options id role-permissions? request-id intro-message)
|
||||||
banList (banned-options id token-permissions intro-message)
|
banList (banned-options id role-permissions? intro-message)
|
||||||
:else (not-joined-options id token-permissions request-id intro-message))))
|
:else (not-joined-options id role-permissions? request-id intro-message))))
|
||||||
|
|
||||||
(defn community-options-bottom-sheet
|
(defn community-options-bottom-sheet
|
||||||
[id]
|
[id]
|
||||||
|
|
Loading…
Reference in New Issue