mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +00:00
Connect to message update events
This commit is contained in:
parent
e6cdcd8ed8
commit
3ce0eeb509
@ -198,6 +198,10 @@ class UserWebSocket {
|
|||||||
SendEvent("newConvMessage", msg.data);
|
SendEvent("newConvMessage", msg.data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "updated_conv_message":
|
||||||
|
SendEvent("updatedConvMessage", msg.data);
|
||||||
|
break;
|
||||||
|
|
||||||
case "new_comment":
|
case "new_comment":
|
||||||
SendEvent("new_comment", msg.data);
|
SendEvent("new_comment", msg.data);
|
||||||
break;
|
break;
|
||||||
|
@ -995,11 +995,15 @@ const ConvChatWindow = {
|
|||||||
updateLink.addEventListener("click", function(){
|
updateLink.addEventListener("click", function(){
|
||||||
ComunicWeb.components.conversations.messageEditor.open(message, function(newContent){
|
ComunicWeb.components.conversations.messageEditor.open(message, function(newContent){
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
DEPRECATED WITH WEBSOCKETS
|
||||||
|
|
||||||
//Apply and parse new message
|
//Apply and parse new message
|
||||||
textMessage.innerHTML = removeHtmlTags(newContent);
|
textMessage.innerHTML = removeHtmlTags(newContent);
|
||||||
ComunicWeb.components.textParser.parse({
|
ComunicWeb.components.textParser.parse({
|
||||||
element: textMessage,
|
element: textMessage,
|
||||||
});
|
});*/
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1166,3 +1170,22 @@ ComunicWeb.components.conversations.chatWindows = ConvChatWindow;
|
|||||||
|
|
||||||
//Register conversations cache cleaning function
|
//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)
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user