Fix posts not being processed by blacklist after post updates
- Blacklisting individual posts was moved into its own function - Fixed Javascript variables being leaked into the user environment - Fixed post qTips being orphaned by replacements by destroying them first - Moved edit form check into post success to avoid repeating post check
This commit is contained in:
@@ -118,24 +118,28 @@ Blacklist.apply = function() {
|
|||||||
var count = 0
|
var count = 0
|
||||||
|
|
||||||
$.each(this.posts(), function(i, post) {
|
$.each(this.posts(), function(i, post) {
|
||||||
var post_count = 0;
|
count += Blacklist.apply_post(post);
|
||||||
$.each(Blacklist.entries, function(j, entry) {
|
|
||||||
if (Blacklist.post_match(post, entry)) {
|
|
||||||
entry.hits += 1;
|
|
||||||
count += 1;
|
|
||||||
post_count += 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (post_count > 0) {
|
|
||||||
Blacklist.post_hide(post);
|
|
||||||
} else {
|
|
||||||
Blacklist.post_unhide(post);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Blacklist.apply_post = function(post) {
|
||||||
|
var post_count = 0;
|
||||||
|
$.each(Blacklist.entries, function(j, entry) {
|
||||||
|
if (Blacklist.post_match(post, entry)) {
|
||||||
|
entry.hits += 1;
|
||||||
|
post_count += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (post_count > 0) {
|
||||||
|
Blacklist.post_hide(post);
|
||||||
|
} else {
|
||||||
|
Blacklist.post_unhide(post);
|
||||||
|
}
|
||||||
|
return post_count;
|
||||||
|
};
|
||||||
|
|
||||||
Blacklist.posts = function() {
|
Blacklist.posts = function() {
|
||||||
return $(".post-preview, #image-container, #c-comments .post, .mod-queue-preview.post-preview");
|
return $(".post-preview, #image-container, #c-comments .post, .mod-queue-preview.post-preview");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
var post_id = <%= @post.id %>;
|
|
||||||
var $post = $(`#post_${post_id}`);
|
|
||||||
|
|
||||||
<% if @post.valid? %>
|
<% if @post.valid? %>
|
||||||
$post.replaceWith("<%= j PostPresenter.preview(@post, show_deleted: true) %>");
|
var $post = $("#post_<%= @post.id %>");
|
||||||
|
<% if !CurrentUser.disable_post_tooltips %>
|
||||||
|
$post.find("img").qtip("destroy", true);
|
||||||
|
<% end %>
|
||||||
|
var $new_post = $("<%= j PostPresenter.preview(@post, show_deleted: true) %>");
|
||||||
|
Danbooru.Blacklist.apply_post($new_post.get(0));
|
||||||
|
$("#post_<%= @post.id %>").replaceWith($new_post);
|
||||||
|
<% if params[:mode] == "quick-edit" %>
|
||||||
|
Danbooru.PostModeMenu.close_edit_form();
|
||||||
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
Danbooru.error(`Post #${post_id}: <%= j @post.errors.full_messages.join("; ") %>`);
|
Danbooru.error(`Post #<%= @post.id %>: <%= j @post.errors.full_messages.join("; ") %>`);
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if @post.valid? && params[:mode] == "quick-edit" %>
|
|
||||||
Danbooru.PostModeMenu.close_edit_form();
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
$(document).trigger("danbooru:post-preview-updated", <%= raw @post.to_json %>);
|
$(document).trigger("danbooru:post-preview-updated", <%= raw @post.to_json %>);
|
||||||
|
|||||||
Reference in New Issue
Block a user