diff --git a/assets/js/common/ws.js b/assets/js/common/ws.js index e915205e..d27ce050 100644 --- a/assets/js/common/ws.js +++ b/assets/js/common/ws.js @@ -205,6 +205,10 @@ class UserWebSocket { case "comment_updated": SendEvent("commentUpdated", msg.data); break; + + case "comment_deleted": + SendEvent("commentDeleted", msg.data); + break; default: console.error("WS Unspported kind of message!", msg); diff --git a/assets/js/components/comments/ui.js b/assets/js/components/comments/ui.js index e44e288f..b5c4edea 100644 --- a/assets/js/components/comments/ui.js +++ b/assets/js/components/comments/ui.js @@ -214,10 +214,6 @@ const CommentsUI = { ComunicWeb.common.notificationSystem.showNotification(lang("comments_ui_err_delete_comment"), "danger"); return; } - - //Delete the comment node - emptyElem(commentContainer); - commentContainer.remove(); }); }); @@ -326,4 +322,16 @@ document.addEventListener("commentUpdated", async (e) => { return; CommentsUI._show_comment(comment, await userInfo(comment.userID), target) -}) \ No newline at end of file +}) + +// Register to comments deletion events +document.addEventListener("commentDeleted", async (e) => { + const commentID = e.detail; + + const target = document.querySelector("[data-comment-id='"+commentID+"']"); + + if(target == null) + return; + + target.remove(); +}); \ No newline at end of file