From 54d8245f91f375e33dc6b10ec2e58599faae083d Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 13 Mar 2021 13:39:03 +0100 Subject: [PATCH] Handle conversation deleted event --- assets/js/common/ws.js | 4 ++++ assets/js/components/conversations/chatWindows.js | 9 +++++++++ assets/js/pages/conversations/conversation.js | 9 ++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/assets/js/common/ws.js b/assets/js/common/ws.js index e33668ee..9b3bc9b6 100644 --- a/assets/js/common/ws.js +++ b/assets/js/common/ws.js @@ -217,6 +217,10 @@ class UserWebSocket { SendEvent("removedUserFromConv", msg.data); break; + case "deleted_conversation": + SendEvent("deletedConversation", msg.data); + 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 dc720e81..e1fda3db 100644 --- a/assets/js/components/conversations/chatWindows.js +++ b/assets/js/components/conversations/chatWindows.js @@ -1505,4 +1505,13 @@ document.addEventListener("removedUserFromConv", e => { return; ConvChatWindow.__conversationsCache["conversation-"+msg.conv_id].box.closeFunction(); +}); + +document.addEventListener("deletedConversation", e => { + const convID = e.detail; + + if(!ConvService.__serviceCache.hasOwnProperty("conversation-" + convID)) + return; + + ConvChatWindow.__conversationsCache["conversation-"+convID].box.closeFunction(); }); \ No newline at end of file diff --git a/assets/js/pages/conversations/conversation.js b/assets/js/pages/conversations/conversation.js index e0ab8875..b4d42def 100644 --- a/assets/js/pages/conversations/conversation.js +++ b/assets/js/pages/conversations/conversation.js @@ -696,6 +696,13 @@ document.addEventListener("deletedConvMessage", (e) => { document.addEventListener("removedUserFromConv", e => { const msg = e.detail; - if (msg.user_id == userID() && ConversationPageConvPart._conv_info.id) + if (msg.user_id == userID() && ConversationPageConvPart._conv_info.id == msg.conv_id) + Page.openPage("conversations"); +}); + +document.addEventListener("deletedConversation", e => { + const convID = e.detail; + + if (ConversationPageConvPart._conv_info.id == convID) Page.openPage("conversations"); }); \ No newline at end of file