Register to comments updateds events

This commit is contained in:
Pierre HUBERT 2020-04-02 11:08:33 +02:00
parent 0344ca5ca9
commit 96ed7a47b8
3 changed files with 18 additions and 4 deletions

View File

@ -202,6 +202,10 @@ class UserWebSocket {
SendEvent("new_comment", msg.data); SendEvent("new_comment", msg.data);
break; break;
case "comment_updated":
SendEvent("commentUpdated", msg.data);
break;
default: default:
console.error("WS Unspported kind of message!", msg); console.error("WS Unspported kind of message!", msg);
break; break;

View File

@ -29,10 +29,6 @@ ComunicWeb.components.comments.editor = {
ComunicWeb.common.notificationSystem.showNotification(lang("comments_editor_err_update"), "danger"); ComunicWeb.common.notificationSystem.showNotification(lang("comments_editor_err_update"), "danger");
return; return;
} }
//Else perform next actions
//Reload the comment
ComunicWeb.components.comments.actions.reload(infos.ID, root);
}); });
} }

View File

@ -113,6 +113,9 @@ const CommentsUI = {
var commentContainer = target; var commentContainer = target;
} }
// Save comment ID for later use
commentContainer.setAttribute("data-comment-id", infos.ID)
//Add user image //Add user image
createElem2({ createElem2({
@ -313,3 +316,14 @@ document.addEventListener("new_comment", async (e) => {
CommentsUI._show_comment(comment, await userInfo(comment.userID), newCommentTarget) CommentsUI._show_comment(comment, await userInfo(comment.userID), newCommentTarget)
}) })
// Register to comments updates events
document.addEventListener("commentUpdated", async (e) => {
const comment = e.detail;
const target = document.querySelector("[data-comment-id='"+comment.ID+"']");
if(target == null)
return;
CommentsUI._show_comment(comment, await userInfo(comment.userID), target)
})