Hide empty categories and categories that include only hidden channels

This commit is contained in:
Parvesh Monu 2024-05-16 15:21:30 +05:30
parent 30715a69e1
commit 052813e30e
No known key found for this signature in database
GPG Key ID: F399696520817DE9
2 changed files with 26 additions and 21 deletions

View File

@ -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

View File

@ -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",