From 59f8320d914adba0cf4c5d1e144c43abd91d025e Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 28 Nov 2021 01:26:09 -0600 Subject: [PATCH] votes: fix bug with tag scripting in show score mode. Fix a bug where scores would disappear when applying tag scripts in show scores mode. --- app/javascript/src/javascripts/posts.js | 5 ++++- app/views/posts/update.js.erb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/javascript/src/javascripts/posts.js b/app/javascript/src/javascripts/posts.js index 85fc8f070..55d5f68a9 100644 --- a/app/javascript/src/javascripts/posts.js +++ b/app/javascript/src/javascripts/posts.js @@ -409,7 +409,10 @@ Post.update = async function(post_id, mode, params) { Post.pending_update_count += 1; Post.show_pending_update_notice() - await $.ajax({ type: "PUT", url: `/posts/${post_id}.js?mode=${mode}`, data: params }); + let urlParams = new URLSearchParams(window.location.search); + let view = urlParams.get("view"); + + await $.ajax({ type: "PUT", url: `/posts/${post_id}.js?mode=${mode}&view=${view}`, data: params }); Post.pending_update_count -= 1; Post.show_pending_update_notice(); diff --git a/app/views/posts/update.js.erb b/app/views/posts/update.js.erb index 226bbecc9..b4314b381 100644 --- a/app/views/posts/update.js.erb +++ b/app/views/posts/update.js.erb @@ -1,6 +1,6 @@ <% if @post.valid? %> var $post = $("#post_<%= @post.id %>"); - var $new_post = $("<%= j post_preview(@post, show_deleted: true) %>"); + var $new_post = $("<%= j post_preview(@post, show_deleted: true, show_votes: params[:view] == "score") %>"); Danbooru.Blacklist.apply_post($new_post.get(0)); $("#post_<%= @post.id %>").replaceWith($new_post); <% if params[:mode] == "quick-edit" %>