From adc5bbf906f23b10ff7122ddfab69ab1ccce03f0 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 14 Jan 2022 21:51:59 -0600 Subject: [PATCH] posts: fix paginator not appearing when all posts are hidden. Fix the paginator not appearing when all posts on the page are hidden, because of deleted posts, banned artists, censored tags, or non-safe posts in safe mode. This prevented navigating to the next or previous page. --- app/javascript/src/javascripts/posts.js | 2 +- app/logical/post_sets/post.rb | 6 --- app/views/posts/index.html.erb | 56 ++++++++++++------------- 3 files changed, 27 insertions(+), 37 deletions(-) diff --git a/app/javascript/src/javascripts/posts.js b/app/javascript/src/javascripts/posts.js index 125ae020d..b2aaec89a 100644 --- a/app/javascript/src/javascripts/posts.js +++ b/app/javascript/src/javascripts/posts.js @@ -355,7 +355,7 @@ Post.initialize_excerpt = function() { e.preventDefault(); }); - if (!$(".post-preview").length && /Nobody here but us chickens/.test($("#posts").html())) { + if (!$(".post-preview").length && /No posts found/.test($("#posts").html())) { $("#show-excerpt-link").click(); } } diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 41b4f461f..5be63d1e8 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -67,12 +67,6 @@ module PostSets posts.any? {|x| x.rating == "e"} end - def shown_posts - shown_posts = posts.select(&:visible?) - shown_posts = shown_posts.reject(&:is_deleted?) unless show_deleted? - shown_posts - end - def hidden_posts posts.reject(&:visible?) end diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index 3827fff35..bdf1c4bfe 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -223,42 +223,38 @@
- <% if @post_set.shown_posts.empty? %> - <%= render "post_sets/blank" %> - <% else %> - <%= render_post_gallery(@post_set.posts, show_deleted: @post_set.show_deleted?, tags: @post_set.tag_string, show_votes: @post_set.show_votes?, size: @preview_size) do |gallery, posts| %> - <% gallery.footer do %> - <% if @post_set.hidden_posts.present? %> -
- <% if @post_set.banned_posts.present? %> - <%= @post_set.banned_posts.size %> post(s) were removed from this page at the artist's request (<%= link_to_wiki "learn more", "banned_artist" %>).
- <% end %> + <%= render_post_gallery(@post_set.posts, show_deleted: @post_set.show_deleted?, tags: @post_set.tag_string, show_votes: @post_set.show_votes?, size: @preview_size) do |gallery, posts| %> + <% gallery.footer do %> + <% if @post_set.hidden_posts.present? %> +
+ <% if @post_set.banned_posts.present? %> + <%= @post_set.banned_posts.size %> post(s) were removed from this page at the artist's request (<%= link_to_wiki "learn more", "banned_artist" %>).
+ <% end %> - <% if @post_set.censored_posts.present? %> - <%= @post_set.censored_posts.size %> post(s) on this page require a <%= link_to "Gold account", new_user_upgrade_path %> to view (<%= link_to_wiki "learn more", "help:censored_tags" %>).
- <% end %> + <% if @post_set.censored_posts.present? %> + <%= @post_set.censored_posts.size %> post(s) on this page require a <%= link_to "Gold account", new_user_upgrade_path %> to view (<%= link_to_wiki "learn more", "help:censored_tags" %>).
+ <% end %> - <% if @post_set.safe_posts.present? %> - <%= @post_set.safe_posts.size %> post(s) on this page were hidden by safe mode. Go to <%= link_to "Danbooru", "https://danbooru.donmai.us" %> or disable safe mode to view them (<%= link_to_wiki "learn more", "help:user_settings" %>).
- <% end %> -
- <% end %> + <% if @post_set.safe_posts.present? %> + <%= @post_set.safe_posts.size %> post(s) on this page were hidden by safe mode. Go to <%= link_to "Danbooru", "https://danbooru.donmai.us" %> or disable safe mode to view them (<%= link_to_wiki "learn more", "help:user_settings" %>).
+ <% end %> +
+ <% end %> - <% if !CurrentUser.user.is_anonymous? && @post_set.tag.present? && @post_set.current_page == 1 %> - <% cache("tag-change-notice:#{@post_set.tag.name}", expires_in: 4.hours) do %> - <% if @post_set.pending_bulk_update_requests.present? %> -
-

- This tag is being discussed in - <%= to_sentence @post_set.pending_bulk_update_requests.map { |bur| link_to "Topic ##{bur.forum_topic_id}: #{bur.forum_topic.title}", bur.forum_post } %>. -

-
- <% end %> + <% if !CurrentUser.user.is_anonymous? && @post_set.tag.present? && @post_set.current_page == 1 %> + <% cache("tag-change-notice:#{@post_set.tag.name}", expires_in: 4.hours) do %> + <% if @post_set.pending_bulk_update_requests.present? %> +
+

+ This tag is being discussed in + <%= to_sentence @post_set.pending_bulk_update_requests.map { |bur| link_to "Topic ##{bur.forum_topic_id}: #{bur.forum_topic.title}", bur.forum_post } %>. +

+
<% end %> <% end %> - - <%= numbered_paginator(posts) %> <% end %> + + <%= numbered_paginator(posts) %> <% end %> <% end %>