Can update conversation color

This commit is contained in:
Pierre HUBERT 2021-03-07 14:08:01 +01:00
parent e32f114179
commit 98906334a7
2 changed files with 21 additions and 25 deletions

View File

@ -606,16 +606,12 @@ const ConvChatWindow = {
showConversationSettings: function(conversation){
//First, check conversation settings button and pane don't exists yet
if(conversation.box.settingsButton){
if(conversation.box.settingsButton.remove){
if(conversation.box.settingsButton && conversation.box.settingsButton.remove){
conversation.box.settingsButton.remove();
}
}
if(conversation.box.settingsPane){
if(conversation.box.settingsPane.remove){
if(conversation.box.settingsPane && conversation.box.settingsPane.remove){
conversation.box.settingsPane.remove();
}
}
//Create and display conversation settings button wheel
conversation.box.settingsButton = createElem2({
@ -659,6 +655,12 @@ const ConvChatWindow = {
if(conversation.infos.name)
settingsForm.conversationNameInput.value = conversation.infos.name;
// Apply conversation color
if (conversation.infos.color) {
settingsForm.conversationColorInput.value = "#" + conversation.infos.color;
settingsForm.conversationColorInput.dispatchEvent(new CustomEvent("change"))
}
//Update conversation members
ComunicWeb.components.userSelect.pushEntries(settingsForm.usersElement, conversation.infos.members.map(m => m.user_id));
@ -669,8 +671,8 @@ const ConvChatWindow = {
//Check if user is a conversation moderator or not
if(!conversation.infos.members.find(m => m.user_id == userID()).is_admin) {
//We disable name field
settingsForm.conversationNameInput.disabled = "true";
settingsForm.conversationNameInput.disabled = true;
settingsForm.conversationColorInput.parentNode.parentNode.style.display = "none";
settingsForm.allowEveryoneToAddMembers.parentNode.parentNode.remove();
}
@ -731,11 +733,14 @@ const ConvChatWindow = {
}
//Add other fields if the user is a conversation moderator
if(conversation.infos.ID_owner == userID()){
if(conversation.infos.members.find(m => m.user_id == userID()).is_admin){
//Specify conversation name
var nameValue = conversation.settingsForm.conversationNameInput.value
let nameValue = conversation.settingsForm.conversationNameInput.value
newValues.name = (nameValue === "" ? false : nameValue);
let colorValue = conversation.settingsForm.conversationColorInput.value
newValues.color = (colorValue == "" ? null : colorValue)
newValues.canEveryoneAddMembers = conversation.settingsForm.allowEveryoneToAddMembers.checked;
}

View File

@ -110,9 +110,8 @@ const ConversationsInterface = {
* @info {Integer} conversationID The ID of the conversation to update
* @info {Boolean} following Specify if the user is following the conversation or not
* @info {String} name Specify a new name for the conversation
* @info {array} members Specify the new list of members for the conversation
* @info {String} color Specify a new color for the conversation
* @param {function} callback The function callback
* @return {Boolean} True for a success
*/
updateSettings: function(infos, callback){
//Prepare the API request
@ -125,10 +124,6 @@ const ConversationsInterface = {
if(infos.name !== undefined)
params.name = infos.name;
//Add conversation members (if specified)
if(infos.members)
params.members = infos.members;
//Add conversation following status (if specified)
if(infos.following !== undefined)
params.following = infos.following;
@ -136,22 +131,18 @@ const ConversationsInterface = {
if(infos.canEveryoneAddMembers !== undefined)
params.canEveryoneAddMembers = infos.canEveryoneAddMembers;
if(infos.color !== undefined)
params.color = infos.color == null ? "" : infos.color.replace("#", "").toUpperCase();
//Perform API request
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(result){
//Empty the cache (considered as deprecated)
ComunicWeb.components.conversations.interface.emptyCache(true);
//Check for error
if(result.error)
ComunicWeb.debug.logMessage("Error! An error occured while trying to update conversation settings !");
//Perform next action
callback(result);
});
//Success
return true;
},
/**