From b99c1e4a7f8a35e670b38ba49636593a7ed9fe61 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 5 Apr 2021 17:08:59 +0200 Subject: [PATCH] Better integration of groups conversations --- assets/js/common/shorcuts.js | 5 +++- .../components/conversations/chatWindows.js | 25 ++++++++++++++++--- assets/js/components/sidebar/main.js | 7 +----- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/assets/js/common/shorcuts.js b/assets/js/common/shorcuts.js index 718322ab..d290a15a 100644 --- a/assets/js/common/shorcuts.js +++ b/assets/js/common/shorcuts.js @@ -222,10 +222,13 @@ function log(message){ * @param {number} id The ID of the conversation to open * @param {bool} fullscreen Specify whether the conversation has to * appear in full screen or not + * @param {number} group_id Related group ID (if any) */ -function openConversation(id, fullscreen = false){ +function openConversation(id, fullscreen = false, group_id){ if(!fullscreen) ComunicWeb.components.conversations.manager.addConversation(id); + else if (group_id) + Page.openPage("groups/" + group_id + "/conversation/" + id); else openPage("conversations/" + id); } diff --git a/assets/js/components/conversations/chatWindows.js b/assets/js/components/conversations/chatWindows.js index e1fda3db..821cec24 100644 --- a/assets/js/components/conversations/chatWindows.js +++ b/assets/js/components/conversations/chatWindows.js @@ -305,7 +305,7 @@ const ConvChatWindow = { this.__conversationsCache["conversation-"+conversationID] = conversationInfos; //Change the name of the conversation - this.changeName(await getConvName(conv), conversationWindow); + this.changeName(await getConvName(conv), conversationWindow, conv); // Apply the color of the conversation (if any) if (conv.color) @@ -395,9 +395,10 @@ const ConvChatWindow = { * * @param {String} newName The new name for the conversation window * @param {Ojbect} info Information about the conversation window + * @param {Conversation} conv Conversation information (if available) * @return {Boolean} True for a success */ - changeName: function(newName, info){ + changeName: function(newName, info, conv){ //Reduce new name if(newName.length > 18) @@ -412,7 +413,7 @@ const ConvChatWindow = { appendTo: info.boxTitle, class: "fa fa-comments", ondblclick: () => { - openConversation(info.conversationID, true); + openConversation(info.conversationID, true, conv ? conv.group_id : null); info.closeFunction(); } }); @@ -429,7 +430,7 @@ const ConvChatWindow = { /** * Update conversation members list * - * @param {Object} conv Information about the conversation + * @param {Object} info Information about the conversation * @return {Boolean} True for a success */ updateMembersList: function(info) { @@ -544,6 +545,9 @@ const ConvChatWindow = { innerHTML: (member.is_admin ? tr("Admin") : tr("Member")) + " " }); + if (conv.group_id) + continue; + // Set / unset admin if(canRemoveUsers && member.user_id != userID()) { @@ -716,6 +720,19 @@ const ConvChatWindow = { settingsForm.allowEveryoneToAddMembers.parentNode.parentNode.remove(); } + // It is not possible to update conversation info in managed conversations + if (conversation.infos.group_id) { + settingsForm.allowEveryoneToAddMembers.parentNode.parentNode.remove(); + + createElem2({ + type: "a", + class: "a", + insertBefore: settingsForm.rootElem.children[0], + innerHTML: "This conversation is managed by a group", + onclick: () => openPage("groups/" + conversation.infos.group_id) + }) + } + //Update follow conversation checkbox status $(settingsForm.followConversationInput).iCheck(conversation.infos.members.find(m => m.user_id == userID()).following ? "check" : "uncheck"); diff --git a/assets/js/components/sidebar/main.js b/assets/js/components/sidebar/main.js index 2ff5fcfa..2833e650 100644 --- a/assets/js/components/sidebar/main.js +++ b/assets/js/components/sidebar/main.js @@ -600,12 +600,7 @@ const SidebarMain = { let a = createElem2({ appendTo: li, type: "a", - onclick: () => { - if (!conv.group_id) - openConversation(conv.id, true) - else - Page.openPage("groups/" + conv.group_id + "/conversation/" + conv.id); - } + onclick: () => openConversation(conv.id, true, conv.group_id) }); // Icon