mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +00:00
Delete comments using websocket help
This commit is contained in:
parent
96ed7a47b8
commit
ac85cd4e6e
@ -206,6 +206,10 @@ class UserWebSocket {
|
|||||||
SendEvent("commentUpdated", msg.data);
|
SendEvent("commentUpdated", msg.data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "comment_deleted":
|
||||||
|
SendEvent("commentDeleted", msg.data);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.error("WS Unspported kind of message!", msg);
|
console.error("WS Unspported kind of message!", msg);
|
||||||
break;
|
break;
|
||||||
|
@ -214,10 +214,6 @@ const CommentsUI = {
|
|||||||
ComunicWeb.common.notificationSystem.showNotification(lang("comments_ui_err_delete_comment"), "danger");
|
ComunicWeb.common.notificationSystem.showNotification(lang("comments_ui_err_delete_comment"), "danger");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete the comment node
|
|
||||||
emptyElem(commentContainer);
|
|
||||||
commentContainer.remove();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -327,3 +323,15 @@ document.addEventListener("commentUpdated", async (e) => {
|
|||||||
|
|
||||||
CommentsUI._show_comment(comment, await userInfo(comment.userID), target)
|
CommentsUI._show_comment(comment, await userInfo(comment.userID), target)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user