From 603594b2152095ba6eba0965a8c922b497146fe5 Mon Sep 17 00:00:00 2001 From: Ruth Date: Wed, 27 Jan 2021 00:37:16 +0300 Subject: [PATCH] remove empty topics on the dashboard (#9075) --- app/views/dashboard_v2/_topicCard.html.erb | 119 ++++++++++----------- 1 file changed, 58 insertions(+), 61 deletions(-) diff --git a/app/views/dashboard_v2/_topicCard.html.erb b/app/views/dashboard_v2/_topicCard.html.erb index 6c7da4c59e..aa711a55d5 100644 --- a/app/views/dashboard_v2/_topicCard.html.erb +++ b/app/views/dashboard_v2/_topicCard.html.erb @@ -1,73 +1,70 @@ <%# Most of this design has been extracted from the tags _topicCard with slight variations %> <% subscriptions ||= @tag_subscriptions # allow overriding with local variable %> <% shown_nids = [@blog.nid] %> -
- <% subscriptions.each do |subscription| %> -
-
- <%# Unfollow section %> - <% if current_user && current_user.following(subscription.tag.name) %> - - - <% end %> - <%# Topic name %> -

<%= subscription.tag.name %>

- <%# Follower count %> -

<%= Tag.follower_count(subscription.tag.name) %> <%= translation('tag.show.following') %>

-
-
- <%# First 3 notes in the Topic %> -
- <% notes = Tag.find_nodes_by_type(subscription.tag.name, type = 'note', limit = 3).where.not(nid: shown_nids) %> -
- <%# TODO fix odd line folding https://github.com/publiclab/plots2/issues/8837 %> - <% if notes.present? %> - <% notes.each do |node| %> - <% shown_nids << node.id %> - <% if node.main_image %> - - <% elsif node.scraped_image %> - - <% else %> -
- <% end %> -
-

- target="_blank"<% end %> href="<%= node.path %>"><%= (node.type == 'note') ? node.title : node.latest.title %> - <%= translation('tag.show.by') %> target="_blank"<% end %> href="/profile/<%= node.author.name %>">@<%= node.author.name %> -

+<% subscriptions.each do |subscription| %> + <% notes = Tag.find_nodes_by_type(subscription.tag.name, type = 'note', limit = 3).where.not(nid: shown_nids) %> + <% if notes.present? %> <%# Topics without notes will not be displayed. If pagination shows many empty pages, refer to https://github.com/publiclab/plots2/issues/8964#issuecomment-763303076 %> +
+
+
+ <%# Unfollow section %> + <% if current_user && current_user.following(subscription.tag.name) %> + + <% end %> + <%# Topic name %> +

<%= subscription.tag.name %>

+ <%# Follower count %> +

<%= Tag.follower_count(subscription.tag.name) %> <%= translation('tag.show.following') %>

+
+
+ <%# First 3 notes in the Topic %> +
+
+ <% notes.each do |node| %> + <% shown_nids << node.id %> + <% if node.main_image %> + + <% elsif node.scraped_image %> + + <% else %> +
+ <% end %> + + <% end %> +
+
+
- <% else %> -

<%= translation('tag.show.notes_not_available') %>

- <% end %> +
-
-
- - -
<% end %> -
+<% end %> + <%# If the items are listed on only one page, the pagination button will not be displayed %> <% if @pagy.pages > 1 %>