From ce0397d5bea1e7b0c952708b46eaa2b775833356 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 7 Mar 2021 19:44:51 +0100 Subject: [PATCH] Redirect user when he is removed from conversation --- assets/js/common/ws.js | 4 ++++ assets/js/pages/conversations/conversation.js | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/assets/js/common/ws.js b/assets/js/common/ws.js index 3b32a904..b3084258 100644 --- a/assets/js/common/ws.js +++ b/assets/js/common/ws.js @@ -209,6 +209,10 @@ class UserWebSocket { SendEvent("deletedConvMessage", msg.data.id); break; + case "removed_user_from_conv": + SendEvent("removedUserFromConv", msg.data); + break; + case "new_comment": SendEvent("new_comment", msg.data); break; diff --git a/assets/js/pages/conversations/conversation.js b/assets/js/pages/conversations/conversation.js index 770b8f87..9f840dc4 100644 --- a/assets/js/pages/conversations/conversation.js +++ b/assets/js/pages/conversations/conversation.js @@ -685,4 +685,12 @@ document.addEventListener("deletedConvMessage", (e) => { return; target.parentNode.remove() -}) \ No newline at end of file +}) + +// Register to conversation removal +document.addEventListener("removedUserFromConv", e => { + const msg = e.detail; + + if (msg.user_id == userID() && ConversationPageConvPart._conv_info.id) + Page.openPage("conversations"); +}); \ No newline at end of file