From 705254627dd6b5e4e0f8c980ccaa4b3daa162a6f Mon Sep 17 00:00:00 2001 From: Cinder Date: Sun, 1 Sep 2024 11:10:19 -0700 Subject: [PATCH] [Blacklist] Separate blacklist display for posts and comments (#741) Apparently, people were really confused by there only being one blacklist before. --- app/javascript/src/javascripts/blacklists.js | 8 +++++++- app/views/posts/partials/index/_blacklist.html.erb | 5 +++++ app/views/posts/show.html.erb | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/javascript/src/javascripts/blacklists.js b/app/javascript/src/javascripts/blacklists.js index 3ccc85edb..6195b73a5 100644 --- a/app/javascript/src/javascripts/blacklists.js +++ b/app/javascript/src/javascripts/blacklists.js @@ -210,7 +210,6 @@ Blacklist.update_styles = function () { for (const filter of Object.values(Blacklist.filters)) allPosts = allPosts.concat(Array.from(filter.matchIDs)); Blacklist.matchedPosts = new Set(allPosts); - console.log("matched", Blacklist.matchedPosts); $(".filter-matches").removeClass("filter-matches"); for (const postID of Blacklist.matchedPosts) @@ -258,6 +257,9 @@ class BlacklistUI { this.$element = $element; this.$counter = $element.find(".blacklisted-count"); + this.post = parseInt($element.attr("post")); + this.hasPost = !Number.isNaN(this.post); + // Collapsable header $element .attr("collapsed", LStorage.Blacklist.Collapsed) @@ -308,6 +310,10 @@ class BlacklistUI { for (const [name, filter] of Object.entries(Blacklist.filters)) { if (filter.matchIDs.size == 0) continue; + // Special case for the posts/show page sidebar + if (this.hasPost && !filter.matchIDs.has(this.post)) + continue; + activeFilters++; if (!filter.enabled) inactiveFilters++; diff --git a/app/views/posts/partials/index/_blacklist.html.erb b/app/views/posts/partials/index/_blacklist.html.erb index dd0fe6f7b..372e8b8f7 100644 --- a/app/views/posts/partials/index/_blacklist.html.erb +++ b/app/views/posts/partials/index/_blacklist.html.erb @@ -1,6 +1,11 @@ +<%# locals: (post_id: nil) %> +
+ post="<%= post_id %>" + <% end %> >
Blacklisted
diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index f1862f57e..44bd2275c 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -3,7 +3,7 @@