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:
Lungu Cristian 2024-04-11 16:27:18 +03:00 committed by GitHub
parent b5962fd83a
commit c875fb33fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 15 deletions

View File

@ -112,12 +112,14 @@
(defn actions
[{: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
locked?
[quo/action-drawer
[[(action-invite-people)
(action-token-requirements)
(when token-gated?
(action-token-requirements))
(action-qr-code chat-id)
(action-share chat-id)]]]
@ -135,7 +137,8 @@
(and inside-chat? (not locked?))
[quo/action-drawer
[[(action-view-members-and-details community-id chat-id)
(action-token-requirements)
(when token-gated?
(action-token-requirements))
(action-mark-as-read)
(action-toggle-muted chat-id muted muted-till chat-type)
(action-notification-settings)

View File

@ -23,7 +23,7 @@
(h/test "joined options - Token Gated"
(h/setup-subs {:communities/my-pending-request-to-join nil
:communities/community {:joined true
:token-permissions []}})
:role-permissions? true}})
(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-community-rules))
@ -52,7 +52,7 @@
(h/test "admin options - Token Gated"
(h/setup-subs {:communities/my-pending-request-to-join nil
:communities/community {:admin true
:token-permissions []}})
:role-permissions? true}})
(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-community-rules))
@ -76,7 +76,7 @@
(h/test "request sent options - Token Gated"
(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/is-truthy (h/get-by-translation-text :t/invite-people-from-contacts))
(h/is-truthy (h/get-by-translation-text :t/view-token-gating))
@ -97,7 +97,7 @@
(h/test "banned options - Token Gated"
(h/setup-subs {:communities/my-pending-request-to-join nil
:communities/community {:banList 100
:token-permissions []}})
:role-permissions? true}})
(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/view-token-gating))
@ -107,7 +107,7 @@
(h/test "banned options - Token Gated"
(h/setup-subs {:communities/my-pending-request-to-join nil
:communities/community {:banList 100
:token-permissions []}})
:role-permissions? true}})
(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/view-token-gating))
@ -118,6 +118,6 @@
(h/setup-subs {:communities/my-pending-request-to-join nil
:communities/community {:joined true
:muted true
:token-permissions []}})
:role-permissions? true}})
(h/render [options/community-options-bottom-sheet {:id "test"}])
(h/is-truthy (h/get-by-translation-text :t/unmute-community))))

View File

@ -180,16 +180,16 @@
(defn get-context-drawers
[{:keys [id]}]
(let [{:keys [token-permissions admin joined
(let [{:keys [role-permissions? admin joined
muted banList muted-till color
intro-message]} (rf/sub [:communities/community id])
request-id (rf/sub [:communities/my-pending-request-to-join id])]
(cond
admin (owner-options id token-permissions muted muted-till intro-message)
joined (joined-options id token-permissions muted muted-till color intro-message)
request-id (join-request-sent-options id token-permissions request-id intro-message)
banList (banned-options id token-permissions intro-message)
:else (not-joined-options id token-permissions request-id intro-message))))
admin (owner-options id role-permissions? muted muted-till intro-message)
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))))
(defn community-options-bottom-sheet
[id]