From f79ef55e3bd312b93d3193a30132592a2255f78a Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 24 Jan 2019 18:14:53 +0100 Subject: [PATCH] Created a function to easily get the name of a conversation --- assets/js/components/conversations/utils.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/assets/js/components/conversations/utils.js b/assets/js/components/conversations/utils.js index 82eb18eb..a931eebb 100644 --- a/assets/js/components/conversations/utils.js +++ b/assets/js/components/conversations/utils.js @@ -54,6 +54,27 @@ ComunicWeb.components.conversations.utils = { return true; }, + /** + * Given a conversation ID, get its name + * + * @param {number} id The ID of the target conversation + * @param {function} onGotName Function called once we have got the name of the conversation + */ + getNameForID: function(id, onGotName){ + + ComunicWeb.components.conversations.interface.getInfosOne(id, function(info){ + + //Check if an error occurred + if(info.error) + return onGotName(false); + + //Get and return the name of the conversation + ComunicWeb.components.conversations.utils.getName(info, onGotName); + + }); + + }, + /** * Create and display a conversation creation / edition form *