From 2e1dc486718491670dd54cfb6dc2b574c70b53d1 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 7 Mar 2021 19:49:34 +0100 Subject: [PATCH] Auto-close conversation chat on user removal --- .../js/components/conversations/chatWindows.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/assets/js/components/conversations/chatWindows.js b/assets/js/components/conversations/chatWindows.js index 2decbaab..a76be814 100644 --- a/assets/js/components/conversations/chatWindows.js +++ b/assets/js/components/conversations/chatWindows.js @@ -1485,4 +1485,18 @@ document.addEventListener("deletedConvMessage", (e) => { return; target.style.display = "none"; -}) \ No newline at end of file +}) + + +// Register to conversation removal +document.addEventListener("removedUserFromConv", e => { + const msg = e.detail; + + if (msg.user_id != userID()) + return; + + if(!ConvService.__serviceCache.hasOwnProperty("conversation-" + msg.conv_id)) + return; + + ConvChatWindow.__conversationsCache["conversation-"+msg.conv_id].box.closeFunction(); +}); \ No newline at end of file