mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-03 19:54:14 +00:00 
			
		
		
		
	Connect to message update events
This commit is contained in:
		@@ -995,11 +995,15 @@ const ConvChatWindow = {
 | 
			
		||||
			updateLink.addEventListener("click", function(){
 | 
			
		||||
				ComunicWeb.components.conversations.messageEditor.open(message, function(newContent){
 | 
			
		||||
					
 | 
			
		||||
					/*
 | 
			
		||||
					
 | 
			
		||||
					DEPRECATED WITH WEBSOCKETS
 | 
			
		||||
 | 
			
		||||
					//Apply and parse new message
 | 
			
		||||
					textMessage.innerHTML = removeHtmlTags(newContent);
 | 
			
		||||
					ComunicWeb.components.textParser.parse({
 | 
			
		||||
						element: textMessage,
 | 
			
		||||
					});
 | 
			
		||||
					});*/
 | 
			
		||||
 | 
			
		||||
				});
 | 
			
		||||
			});
 | 
			
		||||
@@ -1165,4 +1169,23 @@ const ConvChatWindow = {
 | 
			
		||||
ComunicWeb.components.conversations.chatWindows = ConvChatWindow;
 | 
			
		||||
 | 
			
		||||
//Register conversations cache cleaning function
 | 
			
		||||
ComunicWeb.common.cacheManager.registerCacheCleaner("ComunicWeb.components.conversations.chatWindows.unloadAll");
 | 
			
		||||
ComunicWeb.common.cacheManager.registerCacheCleaner("ComunicWeb.components.conversations.chatWindows.unloadAll");
 | 
			
		||||
 | 
			
		||||
// Register to messages update events
 | 
			
		||||
document.addEventListener("updatedConvMessage", (e) => {
 | 
			
		||||
	const msg = e.detail;
 | 
			
		||||
 | 
			
		||||
	// Get message target
 | 
			
		||||
	const target = document.querySelector("[data-chatwin-msg-id='"+msg.ID+"']");
 | 
			
		||||
	if(!target)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	// Get conversation info
 | 
			
		||||
	const convInfo = ConvChatWindow.__conversationsCache["conversation-"+msg.convID];
 | 
			
		||||
	if(!convInfo)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	target.replaceWith(ConvChatWindow._get_message_element(convInfo, msg).rootElem)
 | 
			
		||||
});
 | 
			
		||||
		Reference in New Issue
	
	Block a user