From a6ca315a37843bd7b043e63a58b3fb5092bf728f Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 3 Apr 2020 09:04:41 +0200 Subject: [PATCH] Propagate conversation message to chat window --- assets/js/common/ws.js | 4 ++++ assets/js/components/conversations/chatWindows.js | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/assets/js/common/ws.js b/assets/js/common/ws.js index bc2c6d5f..5444f7bd 100644 --- a/assets/js/common/ws.js +++ b/assets/js/common/ws.js @@ -202,6 +202,10 @@ class UserWebSocket { SendEvent("updatedConvMessage", msg.data); break; + case "deleted_conv_message": + SendEvent("deletedConvMessage", msg.data.ID); + break; + case "new_comment": SendEvent("new_comment", msg.data); break; diff --git a/assets/js/components/conversations/chatWindows.js b/assets/js/components/conversations/chatWindows.js index b1f11968..9086452c 100644 --- a/assets/js/components/conversations/chatWindows.js +++ b/assets/js/components/conversations/chatWindows.js @@ -1188,4 +1188,16 @@ document.addEventListener("updatedConvMessage", (e) => { target.replaceWith(ConvChatWindow._get_message_element(convInfo, msg).rootElem) -}); \ No newline at end of file +}); + +// Register to message deletion events +document.addEventListener("deletedConvMessage", (e) => { + const msgID = e.detail; + + // Get message target + const target = document.querySelector("[data-chatwin-msg-id='"+msgID+"'] .direct-chat-text"); + if(!target) + return; + + target.style.display = "none"; +}) \ No newline at end of file