Skip to content

Commit a3b84ce

Browse files
committed
fix(communities): Stats not shown in discover page
1 parent 8c82a84 commit a3b84ce

File tree

6 files changed

+91
-107
lines changed

6 files changed

+91
-107
lines changed

src/quo/components/community/community_card_view.cljs

+6-5
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,19 @@
5555
[rn/view (style/card-view-chat-icon 48 theme)
5656
[icon/community-icon {:images images} 48]]
5757
(when (= status :gated)
58-
[rn/view (style/permission-tag-styles)
58+
[rn/view style/permission-tag-styles
5959
[community-view/permission-tag-container
6060
{:locked? locked?
6161
:status status
6262
:tokens tokens}]])
6363
[community-view/community-title
6464
{:title name
6565
:description description}]
66-
[rn/view {:style (style/card-stats-position)}
67-
[community-view/community-stats-column
68-
{:type :card-view}]]
69-
[rn/view {:style (style/community-tags-position)}
66+
[rn/view {:style style/card-stats-position}
67+
[community-view/community-stats-column {:type :card-view
68+
:members-count (:members-count community)
69+
:active-members-count (:active-members-count community)}]]
70+
[rn/view {:style style/community-tags-position}
7071
[community-view/community-tags {:tags tags}]]]]]]))
7172

7273
(defn view

src/quo/components/community/community_list_view.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
:style {:border-radius 12
6161
:margin-left 12}}
6262
props)
63-
[rn/view (merge (style/membership-info-container) style)
63+
[rn/view (merge style/membership-info-container style)
6464
[community-icon/community-icon
6565
{:images images} 32]
6666
[rn/view

src/quo/components/community/community_view.cljs

+3-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@
1111
[react-native.gesture :as gesture]))
1212

1313
(defn community-stats-column
14-
[{:keys [type members-count active-count]}]
15-
[rn/view
16-
(if (= type :card-view)
17-
(style/card-stats-container)
18-
(style/list-stats-container))
14+
[{:keys [type members-count active-members-count]}]
15+
[rn/view (if (= type :card-view) style/card-stats-container style/list-stats-container)
1916
[community-stat/view
2017
{:accessibility-label :stats-members-count
2118
:icon :i/group
@@ -24,7 +21,7 @@
2421
[community-stat/view
2522
{:accessibility-label :stats-active-count
2623
:icon :i/active-members
27-
:value active-count}]])
24+
:value active-members-count}]])
2825

2926
(defn community-tags
3027
[{:keys [tags container-style last-item-style]}]

src/quo/components/community/style.cljs

+12-14
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,20 @@
1717
(def detail-container
1818
{:flex 1})
1919

20-
(defn card-stats-container
21-
[]
20+
(def card-stats-container
2221
{:flex-direction :row})
2322

24-
(defn list-stats-container
25-
[]
23+
(def list-stats-container
2624
{:flex-direction :row
2725
:align-items :center})
2826

29-
(defn card-stats-position
30-
[]
27+
(def card-stats-position
3128
{:position :absolute
3229
:top 116
3330
:right 12
3431
:left 12})
3532

36-
(defn community-tags-position
37-
[]
33+
(def community-tags-position
3834
{:position :absolute
3935
:top 154
4036
:right 12
@@ -68,8 +64,7 @@
6864
colors/neutral-90
6965
theme)})
7066

71-
(defn membership-info-container
72-
[]
67+
(def membership-info-container
7368
{:flex-direction :row
7469
:border-radius 16
7570
:align-items :center
@@ -87,8 +82,7 @@
8782
:border-top-left-radius 20
8883
:background-color colors/primary-50-opa-20})
8984

90-
(defn permission-tag-styles
91-
[]
85+
(def permission-tag-styles
9286
{:position :absolute
9387
:top 8
9488
:right 8})
@@ -146,10 +140,14 @@
146140
:background-color (colors/theme-colors colors/white colors/neutral-90 theme)})
147141

148142
(def loading-tags-container
149-
{:margin-top 20 :flex-direction :row :align-items :center})
143+
{:margin-top 20
144+
:flex-direction :row
145+
:align-items :center})
150146

151147
(def loading-stats-container
152-
{:margin-top 20 :flex-direction :row :align-items :center})
148+
{:margin-top 20
149+
:flex-direction :row
150+
:align-items :center})
153151

154152
(defn loading-stat-circle
155153
[theme margin-left]

src/status_im/contexts/communities/actions/leave/events.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
:params [{:id request-to-join-id}]
1919
:on-success #(rf/dispatch [:communities/cancel-request-to-join-success %])
2020
:js-response true
21-
:on-error #(log/error "failed to cancel request to join community" request-to-join-id %)}]}))
21+
:on-error #(log/error "failed to cancel request to join community"
22+
request-to-join-id %)}]}))
2223

2324
(rf/reg-event-fx :communities/left
2425
(fn [_ [response-js]]

src/status_im/contexts/communities/discover/view.cljs

+67-80
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434

3535
(defn screen-title
3636
[]
37-
[rn/view
38-
{:style (style/screen-title-container (safe-area/get-top))}
37+
[rn/view {:style (style/screen-title-container (safe-area/get-top))}
3938
[quo/text
4039
{:accessibility-label :communities-screen-title
4140
:weight :semi-bold
@@ -95,14 +94,14 @@
9594

9695
(defn featured-list
9796
[communities view-type]
98-
(let [view-size (reagent/atom 0)
99-
loaded? (and communities (pos? (count communities)))]
97+
(let [view-size (reagent/atom 0)
98+
set-view-size (fn [e]
99+
(reset! view-size (- (oops/oget e "nativeEvent.layout.width") 40)))
100+
loaded? (and communities (pos? (count communities)))]
100101
(fn []
101102
[rn/view
102103
{:style style/featured-list-container
103-
:on-layout #(swap! view-size
104-
(fn [_]
105-
(- (oops/oget % "nativeEvent.layout.width") 40)))}
104+
:on-layout set-view-size}
106105
(when-not (= @view-size 0)
107106
[rn/flat-list
108107
{:key-fn :id
@@ -132,32 +131,27 @@
132131
[discover-communities-segments selected-tab false]])
133132

134133
(defn other-communities-list
135-
[{:keys [communities communities-ids view-type]}]
134+
[{:keys [communities view-type]}]
136135
[rn/view {:style style/other-communities-container}
137-
(if (and communities (pos? (count communities)))
138-
(map-indexed
139-
(fn [inner-index item]
140-
(let [community-id (when communities-ids item)
141-
community (if communities
142-
item
143-
(rf/sub [:communities/home-item community-id]))
144-
cover {:uri (get-in (:images item) [:banner :uri])}]
145-
[rn/view
146-
{:key (str inner-index (:id community))
147-
:margin-bottom 16}
148-
(if (= view-type :card-view)
149-
[quo/community-card-view-item
150-
{:community (assoc community :cover cover)
151-
:on-press #(rf/dispatch [:communities/navigate-to-community-overview (:id community)])}]
152-
153-
[quo/community-list
154-
{:on-press (fn []
155-
(rf/dispatch [:dismiss-keyboard])
156-
(rf/dispatch [:communities/navigate-to-community-overview
157-
(:id community)]))
158-
:on-long-press #(js/alert "TODO: to be implemented")}
159-
community])]))
160-
(if communities communities communities-ids))
136+
(if (seq communities)
137+
(map-indexed (fn [inner-index {community-id :id :as community}]
138+
(let [cover {:uri (-> community :images :banner :uri)}]
139+
[rn/view
140+
{:key (str inner-index community-id)
141+
:style {:margin-bottom 16}}
142+
(if (= view-type :card-view)
143+
[quo/community-card-view-item
144+
{:community (assoc community :cover cover
145+
:members-count (count (:members community)))
146+
:on-press #(rf/dispatch [:communities/navigate-to-community-overview community-id])}]
147+
[quo/community-list
148+
{:on-press (fn []
149+
(rf/dispatch [:dismiss-keyboard])
150+
(rf/dispatch [:communities/navigate-to-community-overview
151+
community-id]))
152+
:on-long-press #(js/alert "TODO: to be implemented")}
153+
community])]))
154+
communities)
161155
[:<>
162156
[rn/view {:margin-bottom 16} [quo/community-card-view-item {:loading? true}]]
163157
[rn/view {:margin-bottom 16} [quo/community-card-view-item {:loading? true}]]
@@ -168,8 +162,8 @@
168162
[rn/view {:style {:flex 1}}
169163
(case @selected-tab
170164
:all
171-
(other-communities-list {:communities (rf/sub [:communities/other-contract-communities])
172-
:view-type view-type})
165+
[other-communities-list {:communities (rf/sub [:communities/other-contract-communities])
166+
:view-type view-type}]
173167

174168
:open
175169
[:<>]
@@ -183,60 +177,53 @@
183177
(i18n/label :t/error)])])
184178

185179
(defn render-communities
186-
[selected-tab
187-
featured-communities-count
188-
featured-communities
189-
view-type]
190-
(fn []
191-
[rn/view
192-
[discover-communities-header
193-
{:selected-tab selected-tab
194-
:view-type view-type
195-
:featured-communities-count featured-communities-count
196-
:featured-communities featured-communities}]
197-
[communities-lists selected-tab view-type]]))
180+
[{:keys [selected-tab featured-communities-count featured-communities view-type]}]
181+
[rn/view
182+
[discover-communities-header
183+
{:selected-tab selected-tab
184+
:view-type view-type
185+
:featured-communities-count featured-communities-count
186+
:featured-communities featured-communities}]
187+
[communities-lists selected-tab view-type]])
198188

199189
(defn render-sticky-header
200190
[{:keys [selected-tab scroll-height]}]
201-
(fn []
202-
(when (> @scroll-height 360)
203-
[rn/view
204-
{:style (style/blur-tabs-header (safe-area/get-top))}
205-
[discover-communities-segments selected-tab true]])))
191+
(when (> @scroll-height 360)
192+
[rn/view
193+
{:style (style/blur-tabs-header (safe-area/get-top))}
194+
[discover-communities-segments selected-tab true]]))
206195

207-
(defn discover-screen-content
208-
[featured-communities theme]
196+
(defn discover-screen-content []
209197
(let [view-type (reagent/atom :card-view)
210198
selected-tab (reagent/atom :all)
211-
scroll-height (reagent/atom 0)
212-
featured-communities-count (count featured-communities)]
199+
scroll-height (reagent/atom 0)]
213200
(fn []
214-
[scroll-page/scroll-page
215-
{:on-scroll #(reset! scroll-height %)
216-
:page-nav-props {:background :blur}
217-
:navigate-back? :true
218-
:height (if (> @scroll-height 360)
219-
208
220-
148)
221-
:background-color (colors/theme-colors colors/white colors/neutral-95 theme)
222-
:sticky-header [render-sticky-header
223-
{:selected-tab selected-tab
224-
:scroll-height scroll-height}]}
225-
226-
[render-communities
227-
selected-tab
228-
featured-communities-count
229-
featured-communities
230-
@view-type]])))
201+
(let [theme (quo.theme/use-theme)
202+
featured-communities (rf/sub [:communities/featured-contract-communities])
203+
featured-communities-count (count featured-communities)]
204+
[scroll-page/scroll-page
205+
{:on-scroll #(reset! scroll-height %)
206+
:page-nav-props {:background :blur}
207+
:navigate-back? :true
208+
:height (if (> @scroll-height 360)
209+
208
210+
148)
211+
:background-color (colors/theme-colors colors/white colors/neutral-95 theme)
212+
:sticky-header [render-sticky-header
213+
{:selected-tab selected-tab
214+
:scroll-height scroll-height}]}
215+
[render-communities
216+
{:selected-tab selected-tab
217+
:featured-communities-count featured-communities-count
218+
:featured-communities featured-communities
219+
:view-type @view-type}]]))))
231220

232221
(defn view
233222
[]
234-
(let [theme (quo.theme/use-theme)
235-
featured-communities (rf/sub [:communities/featured-contract-communities])]
223+
(let [theme (quo.theme/use-theme)]
236224
(rn/use-mount #(rf/dispatch [:fetch-contract-communities]))
237-
[rn/view
238-
{:style (style/discover-screen-container (colors/theme-colors
239-
colors/white
240-
colors/neutral-95
241-
theme))}
242-
[discover-screen-content featured-communities theme]]))
225+
[rn/view {:style (style/discover-screen-container (colors/theme-colors
226+
colors/white
227+
colors/neutral-95
228+
theme))}
229+
[discover-screen-content]]))

0 commit comments

Comments
 (0)