Compare commits

..
Author SHA1 Message Date
Icaro Motta e3a589b2b8 Handle missing user & dev.user namespaces 2024-05-10 14:18:53 -03:00
8 changed files with 45 additions and 62 deletions
+8 -1
View File
@@ -53,7 +53,14 @@
:dev {:devtools {:before-load-async status-im.setup.hot-reload/before-reload
:after-load-async status-im.setup.hot-reload/reload
:build-notify status-im.setup.hot-reload/build-notify
:preloads [re-frisk-remote.preload
:preloads [;; We preload user namespaces so that
;; their symbols are available without
;; the developer having to manually
;; evaluate them after app
;; initialization.
user
dev.user
re-frisk-remote.preload
status-im.setup.schema-preload
;; In order to use component test helpers in the REPL we
;; need to preload namespaces that are not normally required
+2
View File
@@ -0,0 +1,2 @@
;; Placeholder namespace. Replace it at your own discretion.
(ns dev.user)
@@ -9,31 +9,26 @@
[schema.core :as schema]))
(defn- description-comp
[description members-count active-members-count show-members-count?]
(let [has-members? (pos? members-count)
has-active-members? (pos? active-members-count)]
[rn/view
[text/text
{:size :paragraph-2
:number-of-lines 3
:accessibility-label :description}
description]
(when show-members-count?
[rn/view
{:style style/stat-container}
(when has-members?
[community-stat/view
{:value members-count
:icon :i/members
:accessibility-label :members-count
:style {:margin-right 12}
: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}])])]))
[description members-count active-members-count]
[rn/view
[text/text
{:size :paragraph-2
:number-of-lines 3
:accessibility-label :description}
description]
[rn/view {:style style/stat-container}
[community-stat/view
{:value members-count
:icon :i/members
:accessibility-label :members-count
:style {:margin-right 12}
:text-size :paragraph-2}]
(when active-members-count
[community-stat/view
{:value active-members-count
:icon :i/active-members
:accessibility-label :active-members-count
:text-size :paragraph-2}])]])
(defn- title-comp
[title]
@@ -79,7 +74,7 @@
(defn- view-internal
[{:keys [title description loading? icon banner members-count active-members-count
on-press size show-members-count?]}]
on-press size]}]
(let [theme (quo.theme/use-theme)]
[rn/pressable
{:style (style/container size theme)
@@ -93,7 +88,7 @@
[logo-comp icon])
[title-comp title]]
(when description
[description-comp description members-count active-members-count show-members-count?])
[description-comp description members-count active-members-count])
(when banner
[thumbnail-comp banner size])])]))
@@ -34,8 +34,7 @@
:members-count "20"
:loading? false
:active-members-count "15"
:type :community
:show-members-count? true})
:type :community})
(h/describe "Internal link card - Community"
(h/test "renders with most common props"
@@ -18,6 +18,5 @@
[:active-members-count {:optional true} [:maybe [:or :int :string]]]
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
[:emoji-hash {:optional true} [:maybe :string]]
[:size {:optional true} [:maybe :keyword]]
[:show-members-count? {:optional true} [:maybe :boolean]]]]]
[:size {:optional true} [:maybe :keyword]]]]]
:any])
@@ -15,19 +15,14 @@
community-icon :icon
community-banner :banner
community-name :display-name
members-count :members-count
community-id :community-id} community
token-gated-not-a-member? (rf/sub
[:communities/token-gated-not-a-member?
community-id])]
members-count :members-count} community]
^{:key url}
[quo/internal-link-card
{:type :community
:size :message
:description community-description
:members-count members-count
:title community-name
:banner (:url community-banner)
:icon (:url community-icon)
:on-press #(rf/dispatch [:universal-links/handle-url url])
:show-members-count? token-gated-not-a-member?}])))])))
{:type :community
:size :message
:description community-description
:members-count members-count
:title community-name
:banner (:url community-banner)
:icon (:url community-icon)
:on-press #(rf/dispatch [:universal-links/handle-url url])}])))])))
-16
View File
@@ -427,19 +427,3 @@
(fn [[permissions] _]
(let [all-tokens (apply concat (map :tokens permissions))]
(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)))))
+2
View File
@@ -0,0 +1,2 @@
;; Placeholder namespace. Replace it at your own discretion.
(ns user)