From 5ba71f2a7970a475cb0e78573fbe9cd2b01f961c Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 12 Jan 2022 12:52:01 -0600 Subject: [PATCH] Fix #4840: Forum post interface is not updated correctly after deletion. Re-render and replace the whole forum post with AJAX when a forum post is deleted or undeleted. This is easier now that forum posts are componentized. --- app/views/forum_posts/destroy.js.erb | 2 +- app/views/forum_posts/undelete.js.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/forum_posts/destroy.js.erb b/app/views/forum_posts/destroy.js.erb index 146cb8573..7ccf4d7cd 100644 --- a/app/views/forum_posts/destroy.js.erb +++ b/app/views/forum_posts/destroy.js.erb @@ -1 +1 @@ -$("article[data-forum-post-id=<%= @forum_post.id %>] div.author div.author-name").append(" (deleted)"); +$("#forum_post_<%= @forum_post.id %>").replaceWith("<%= j render(ForumPostComponent.new(forum_post: @forum_post, current_user: CurrentUser.user)) %>"); diff --git a/app/views/forum_posts/undelete.js.erb b/app/views/forum_posts/undelete.js.erb index 345366b9b..7ccf4d7cd 100644 --- a/app/views/forum_posts/undelete.js.erb +++ b/app/views/forum_posts/undelete.js.erb @@ -1 +1 @@ -location.reload(); +$("#forum_post_<%= @forum_post.id %>").replaceWith("<%= j render(ForumPostComponent.new(forum_post: @forum_post, current_user: CurrentUser.user)) %>");