mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-29 15:26:27 +00:00
Add support for conversation messages update on conversation page
This commit is contained in:
parent
3ce0eeb509
commit
3b0c696bed
@ -4,7 +4,7 @@
|
|||||||
* @author Pierre HUBERT
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ComunicWeb.pages.conversations.conversation = {
|
const ConversationPageConvPart = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conversation information
|
* Conversation information
|
||||||
@ -274,16 +274,18 @@ ComunicWeb.pages.conversations.conversation = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Add message content container
|
//Add message content container
|
||||||
var messageContentContainer = createElem2({
|
const messageContentContainer = createElem2({
|
||||||
appendTo: messageContainer,
|
appendTo: messageContainer,
|
||||||
type: "div",
|
type: "div",
|
||||||
class: "direct-chat-text",
|
class: "direct-chat-text",
|
||||||
});
|
});
|
||||||
|
messageContentContainer.setAttribute("data-chatpage-msg-text-id", info.ID)
|
||||||
|
|
||||||
//Message content
|
//Message content
|
||||||
var messageContent = createElem2({
|
var messageContent = createElem2({
|
||||||
appendTo: messageContentContainer,
|
appendTo: messageContentContainer,
|
||||||
type: "div",
|
type: "div",
|
||||||
|
class: "txt",
|
||||||
innerHTML: removeHtmlTags(info.message)
|
innerHTML: removeHtmlTags(info.message)
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -587,6 +589,8 @@ ComunicWeb.pages.conversations.conversation = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ComunicWeb.pages.conversations.conversation = ConversationPageConvPart;
|
||||||
|
|
||||||
// Register to new messages
|
// Register to new messages
|
||||||
document.addEventListener("newConvMessage", (e) => {
|
document.addEventListener("newConvMessage", (e) => {
|
||||||
const msg = e.detail;
|
const msg = e.detail;
|
||||||
@ -594,3 +598,27 @@ document.addEventListener("newConvMessage", (e) => {
|
|||||||
if(ComunicWeb.pages.conversations.conversation._conv_info.id == msg.convID)
|
if(ComunicWeb.pages.conversations.conversation._conv_info.id == msg.convID)
|
||||||
ComunicWeb.pages.conversations.conversation.applyMessages([msg]);
|
ComunicWeb.pages.conversations.conversation.applyMessages([msg]);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Register to message update events
|
||||||
|
document.addEventListener("updatedConvMessage", (e) => {
|
||||||
|
const msg = e.detail;
|
||||||
|
|
||||||
|
const target = document.querySelector("[data-chatpage-msg-text-id='"+msg.ID+"'] .txt")
|
||||||
|
if(!target)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
//Message content
|
||||||
|
const newMessageContent = createElem2({
|
||||||
|
type: "div",
|
||||||
|
class: "txt",
|
||||||
|
innerHTML: removeHtmlTags(msg.message)
|
||||||
|
});
|
||||||
|
|
||||||
|
//Parse message content
|
||||||
|
ComunicWeb.components.textParser.parse({
|
||||||
|
element: newMessageContent
|
||||||
|
});
|
||||||
|
|
||||||
|
target.replaceWith(newMessageContent)
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user