From 74e81f7fafa01b79dec92a61861fb79561302260 Mon Sep 17 00:00:00 2001 From: Goran Jovic Date: Wed, 18 Oct 2017 12:41:22 +0200 Subject: [PATCH] bug #2205 - discover all links are disabled when empty --- .../ui/screens/discover/components/views.cljs | 3 +- src/status_im/ui/screens/discover/views.cljs | 54 ++++++++++--------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/status_im/ui/screens/discover/components/views.cljs b/src/status_im/ui/screens/discover/components/views.cljs index 4bee7454a3..f5c7957030 100644 --- a/src/status_im/ui/screens/discover/components/views.cljs +++ b/src/status_im/ui/screens/discover/components/views.cljs @@ -17,7 +17,8 @@ [react/text {:style styles/title-text :font :medium} (i18n/label label-kw)] - [react/touchable-highlight {:on-press action-fn} + [react/touchable-highlight {:on-press action-fn + :disabled (not active?)} [react/view {} ;; NOTE(oskarth): text-transform to uppercase not supported as RN style ;; https://github.com/facebook/react-native/issues/2088 diff --git a/src/status_im/ui/screens/discover/views.cljs b/src/status_im/ui/screens/discover/views.cljs index 57502a7b26..a3aae56ec4 100644 --- a/src/status_im/ui/screens/discover/views.cljs +++ b/src/status_im/ui/screens/discover/views.cljs @@ -69,35 +69,37 @@ (defview popular-hashtags-preview [{:keys [contacts current-account]}] (letsubs [popular-tags [:get-popular-tags 10]] - [react/view styles/popular-container - ;; TODO (goranjovic) - refactor double dispatch to a single call - [components/title :t/popular-tags :t/all #(do (re-frame/dispatch [:set :discover-search-tags (map :name popular-tags)]) - (re-frame/dispatch [:navigate-to :discover-all-hashtags])) true] - (if (seq popular-tags) + (let [has-content? (seq popular-tags)] + [react/view styles/popular-container + ;; TODO (goranjovic) - refactor double dispatch to a single call + [components/title :t/popular-tags :t/all #(do (re-frame/dispatch [:set :discover-search-tags (map :name popular-tags)]) + (re-frame/dispatch [:navigate-to :discover-all-hashtags])) has-content?] + (if has-content? + [carousel/carousel {:pageStyle styles/carousel-page-style + :gap 8 + :sneak 16 + :count (count popular-tags)} + (for [{:keys [name]} popular-tags] + [top-status-for-popular-hashtag {:tag name + :contacts contacts + :current-account current-account}])] + [empty-section :empty-hashtags :t/no-hashtags-discovered-title :t/no-hashtags-discovered-body])]))) + +(defn recent-statuses-preview [current-account discoveries] + (let [has-content? (seq discoveries)] + [react/view styles/recent-statuses-preview-container + [components/title :t/recent :t/all #(re-frame/dispatch [:navigate-to :discover-all-recent]) has-content?] + (if has-content? [carousel/carousel {:pageStyle styles/carousel-page-style :gap 8 :sneak 16 - :count (count popular-tags)} - (for [{:keys [name]} popular-tags] - [top-status-for-popular-hashtag {:tag name - :contacts contacts - :current-account current-account}])] - [empty-section :empty-hashtags :t/no-hashtags-discovered-title :t/no-hashtags-discovered-body])])) - -(defn recent-statuses-preview [current-account discoveries] - [react/view styles/recent-statuses-preview-container - [components/title :t/recent :t/all #(re-frame/dispatch [:navigate-to :discover-all-recent]) true] - (if (seq discoveries) - [carousel/carousel {:pageStyle styles/carousel-page-style - :gap 8 - :sneak 16 - :count (count discoveries)} - (for [discovery discoveries] - [react/view styles/recent-statuses-preview-content - [components/discover-list-item {:message discovery - :show-separator? false - :current-account current-account}]])] - [empty-section :empty-recent :t/no-statuses-discovered :t/no-statuses-discovered-body])]) + :count (count discoveries)} + (for [discovery discoveries] + [react/view styles/recent-statuses-preview-content + [components/discover-list-item {:message discovery + :show-separator? false + :current-account current-account}]])] + [empty-section :empty-recent :t/no-statuses-discovered :t/no-statuses-discovered-body])])) (def public-chats-mock-data [{:name "Status team"