Compare commits

...
15 Commits
Author SHA1 Message Date
ibrkhalil 757d731eed Show community members if a member permission doesn't exist 2024-05-11 10:31:56 +03:00
ibrkhalil 7b536451ef Fix component tests 2024-05-11 07:25:42 +03:00
ibrkhalil 13febab085 Rebase 2024-05-11 07:25:42 +03:00
ibrkhalil 7a3652c8eb Less confusion 2024-05-11 07:25:41 +03:00
ibrkhalil 925bf82621 Chus idea, hide count by default until community data is in app-db if the data doesn't exist 2024-05-11 07:25:41 +03:00
ibrkhalil d1c36e32c7 clean 2024-05-11 07:25:40 +03:00
ibrkhalil 248354e868 Directory changes and following guidelines 2024-05-11 07:25:39 +03:00
ibrkhalil d2fc803f47 grammar 2024-05-11 07:25:39 +03:00
ibrkhalil 641523f011 Update case information 2024-05-11 07:25:38 +03:00
ibrkhalil af993cc227 Update KNOWN_ISSUES.md 2024-05-11 07:25:38 +03:00
Ibrahem Khalil 3c36577e26 clean 2024-05-11 07:25:37 +03:00
Ibrahem Khalil 9bc9998b49 clean 2024-05-11 07:25:37 +03:00
Ibrahem Khalil aa1ce42079 clean 2024-05-11 07:25:36 +03:00
Ibrahem Khalil cabe377938 clean 2024-05-11 07:25:36 +03:00
Ibrahem Khalil 5e5989ffa7 Hide member count on token-gated community link preview 2024-05-11 07:25:35 +03:00
5 changed files with 61 additions and 33 deletions
@@ -9,26 +9,31 @@
[schema.core :as schema])) [schema.core :as schema]))
(defn- description-comp (defn- description-comp
[description members-count active-members-count] [description members-count active-members-count show-members-count?]
[rn/view (let [has-members? (pos? members-count)
[text/text has-active-members? (pos? active-members-count)]
{:size :paragraph-2 [rn/view
:number-of-lines 3 [text/text
:accessibility-label :description} {:size :paragraph-2
description] :number-of-lines 3
[rn/view {:style style/stat-container} :accessibility-label :description}
[community-stat/view description]
{:value members-count (when show-members-count?
:icon :i/members [rn/view
:accessibility-label :members-count {:style style/stat-container}
:style {:margin-right 12} (when has-members?
:text-size :paragraph-2}] [community-stat/view
(when active-members-count {:value members-count
[community-stat/view :icon :i/members
{:value active-members-count :accessibility-label :members-count
:icon :i/active-members :style {:margin-right 12}
:accessibility-label :active-members-count :text-size :paragraph-2}])
:text-size :paragraph-2}])]]) (when has-active-members?
[community-stat/view
{:value active-members-count
:icon :i/active-members
:accessibility-label :active-members-count
:text-size :paragraph-2}])])]))
(defn- title-comp (defn- title-comp
[title] [title]
@@ -74,7 +79,7 @@
(defn- view-internal (defn- view-internal
[{:keys [title description loading? icon banner members-count active-members-count [{:keys [title description loading? icon banner members-count active-members-count
on-press size]}] on-press size show-members-count?]}]
(let [theme (quo.theme/use-theme)] (let [theme (quo.theme/use-theme)]
[rn/pressable [rn/pressable
{:style (style/container size theme) {:style (style/container size theme)
@@ -88,7 +93,7 @@
[logo-comp icon]) [logo-comp icon])
[title-comp title]] [title-comp title]]
(when description (when description
[description-comp description members-count active-members-count]) [description-comp description members-count active-members-count show-members-count?])
(when banner (when banner
[thumbnail-comp banner size])])])) [thumbnail-comp banner size])])]))
@@ -34,7 +34,8 @@
:members-count "20" :members-count "20"
:loading? false :loading? false
:active-members-count "15" :active-members-count "15"
:type :community}) :type :community
:show-members-count? true})
(h/describe "Internal link card - Community" (h/describe "Internal link card - Community"
(h/test "renders with most common props" (h/test "renders with most common props"
@@ -18,5 +18,6 @@
[:active-members-count {:optional true} [:maybe [:or :int :string]]] [:active-members-count {:optional true} [:maybe [:or :int :string]]]
[:customization-color {:optional true} [:maybe :schema.common/customization-color]] [:customization-color {:optional true} [:maybe :schema.common/customization-color]]
[:emoji-hash {:optional true} [:maybe :string]] [:emoji-hash {:optional true} [:maybe :string]]
[:size {:optional true} [:maybe :keyword]]]]] [:size {:optional true} [:maybe :keyword]]
[:show-members-count? {:optional true} [:maybe :boolean]]]]]
:any]) :any])
@@ -15,14 +15,19 @@
community-icon :icon community-icon :icon
community-banner :banner community-banner :banner
community-name :display-name community-name :display-name
members-count :members-count} community] members-count :members-count
community-id :community-id} community
token-gated-not-a-member? (rf/sub
[:communities/token-gated-not-a-member?
community-id])]
^{:key url} ^{:key url}
[quo/internal-link-card [quo/internal-link-card
{:type :community {:type :community
:size :message :size :message
:description community-description :description community-description
:members-count members-count :members-count members-count
:title community-name :title community-name
:banner (:url community-banner) :banner (:url community-banner)
:icon (:url community-icon) :icon (:url community-icon)
:on-press #(rf/dispatch [:universal-links/handle-url url])}])))]))) :on-press #(rf/dispatch [:universal-links/handle-url url])
:show-members-count? token-gated-not-a-member?}])))])))
+16
View File
@@ -427,3 +427,19 @@
(fn [[permissions] _] (fn [[permissions] _]
(let [all-tokens (apply concat (map :tokens permissions))] (let [all-tokens (apply concat (map :tokens permissions))]
(boolean (some seq all-tokens))))) (boolean (some seq all-tokens)))))
(re-frame/reg-sub
:communities/token-gated-not-a-member?
(fn [[_ community-id]]
[(re-frame/subscribe [:communities/community community-id])])
(fn [{:keys [token-permissions joined] :as community}]
(let [token-permission-to-become-member-or-admin (->> token-permissions
(into {})
vals
(some (fn [{community-permission-type :type}]
(boolean
(constants/community-role-permissions
community-permission-type)))))]
(or joined
(and (not joined) (empty? token-permissions) (seq community))
(not token-permission-to-become-member-or-admin)))))