mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Register to comments updateds events
This commit is contained in:
		@@ -202,6 +202,10 @@ class UserWebSocket {
 | 
			
		||||
				SendEvent("new_comment", msg.data);
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			case "comment_updated":
 | 
			
		||||
				SendEvent("commentUpdated", msg.data);
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			default:
 | 
			
		||||
				console.error("WS Unspported kind of message!", msg);
 | 
			
		||||
				break;
 | 
			
		||||
 
 | 
			
		||||
@@ -29,10 +29,6 @@ ComunicWeb.components.comments.editor = {
 | 
			
		||||
					ComunicWeb.common.notificationSystem.showNotification(lang("comments_editor_err_update"), "danger");
 | 
			
		||||
					return;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				//Else perform next actions
 | 
			
		||||
				//Reload the comment
 | 
			
		||||
				ComunicWeb.components.comments.actions.reload(infos.ID, root);
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -113,6 +113,9 @@ const CommentsUI = {
 | 
			
		||||
			var commentContainer = target;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Save comment ID for later use
 | 
			
		||||
		commentContainer.setAttribute("data-comment-id", infos.ID)
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		//Add user image
 | 
			
		||||
		createElem2({
 | 
			
		||||
@@ -313,3 +316,14 @@ document.addEventListener("new_comment", async (e) => {
 | 
			
		||||
 | 
			
		||||
	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)	
 | 
			
		||||
})
 | 
			
		||||
		Reference in New Issue
	
	Block a user