From 052813e30ed309b28ffae0af822ad6f52ed8a02d Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Thu, 16 May 2024 15:21:30 +0530 Subject: [PATCH] Hide empty categories and categories that include only hidden channels --- .../contexts/communities/overview/view.cljs | 45 ++++++++++--------- translations/en.json | 2 + 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/status_im/contexts/communities/overview/view.cljs b/src/status_im/contexts/communities/overview/view.cljs index 6f718c7d88..ad72ba2a8d 100644 --- a/src/status_im/contexts/communities/overview/view.cljs +++ b/src/status_im/contexts/communities/overview/view.cljs @@ -73,25 +73,26 @@ (into #{} (map (comp :name second) channels-list))) :style (style/channel-list-component)} (for [[category-id {:keys [chats name collapsed?]}] channels-list] - [rn/view - {:key category-id - ;; on-layout fires only when the component re-renders, so - ;; in case the category hasn't changed, it will not be fired - :on-layout #(on-category-layout name category-id (int (layout-y %)))} - (when-not (= constants/empty-category-id category-id) - [quo/divider-label - {:on-press #(collapse-category community-id category-id collapsed?) - :chevron-icon (if collapsed? :i/chevron-right :i/chevron-down) - :chevron :left} - name]) - (when-not collapsed? - [rn/view {:style {:padding-horizontal 8}} - (let [last-item-index (dec (count chats))] - (map-indexed - (fn [index chat] - ^{:key (:id chat)} - [channel-chat-item community-id chat (= index last-item-index)]) - chats))])])]) + (when (seq chats) + [rn/view + {:key category-id + ;; on-layout fires only when the component re-renders, so + ;; in case the category hasn't changed, it will not be fired + :on-layout #(on-category-layout name category-id (int (layout-y %)))} + (when-not (= constants/empty-category-id category-id) + [quo/divider-label + {:on-press #(collapse-category community-id category-id collapsed?) + :chevron-icon (if collapsed? :i/chevron-right :i/chevron-down) + :chevron :left} + name]) + (when-not collapsed? + [rn/view {:style {:padding-horizontal 8}} + (let [last-item-index (dec (count chats))] + (map-indexed + (fn [index chat] + ^{:key (:id chat)} + [channel-chat-item community-id chat (= index last-item-index)]) + chats))])]))]) (defn- get-access-type [access] @@ -379,7 +380,7 @@ :fetching-community-overview :failed-to-fetch-community-overview)} [quo/page-nav - {:title "Community Overview" + {:title (i18n/label :t/community-overview) :type :title :text-align :left :icon-name :i/close @@ -387,7 +388,9 @@ [quo/empty-state {:image (resources/get-themed-image :cat-in-box theme) :description (when-not fetching? (i18n/label :t/here-is-a-cat-in-a-box-instead)) - :title (if fetching? "Fetching community..." "Failed to fetch community") + :title (if fetching? + (i18n/label :t/fetching-community) + (i18n/label :t/failed-to-fetch-community)) :container-style {:flex 1 :justify-content :center}}]])) (defn- community-card-page-view diff --git a/translations/en.json b/translations/en.json index 86c18c6b18..92b2df5b95 100644 --- a/translations/en.json +++ b/translations/en.json @@ -268,6 +268,7 @@ "community-color": "Community colour", "community-link": "Community link", "community-color-placeholder": "Pick a colour", + "community-overview": "Community Overview", "membership-button": "Membership requirement", "membership-none": "None", "membership-none-placeholder": "You can require new members to meet certain criteria before they can join. This can be changed at any time", @@ -1565,6 +1566,7 @@ "with-full-encryption": "With full metadata privacy and e2e encryption", "fetch-community": "Fetch community", "fetching-community": "Fetching community...", + "failed-to-fetch-community": "Failed to fetch community", "seed-phrase-placeholder": "Type or paste your recovery phrase", "seed-phrase-words-exceeded": "Recovery phrase cannot exceed 24 words", "seed-phrase-words-uppercase": "Recovery phrase cannot contain uppercase characters",