Send refresh conversation request on the server

This commit is contained in:
Pierre 2017-06-25 16:15:23 +02:00
parent 05c67afe9f
commit 090b8bd77a
3 changed files with 38 additions and 2 deletions

View File

@ -264,6 +264,34 @@ ComunicWeb.components.conversations.interface = {
},
/**
* Refresh a conversation
*
* @param {Array} newConversations New conversations (which requires the 10 last messages)
* @param {Object} toRefresh Conversations to refresh
* @param {Function} callback The callback function
* @return {Boolean} True for a success
*/
refreshConversations: function(newConversations, toRefresh, callback){
//DEBUG log informations
console.log("New conversations", newConversations);
console.log("To refresh", toRefresh);
//Perform a request on the API
var apiURI = "conversations/refresh";
var params = {
newConversations: newConversations,
toRefresh: JSON.stringify(toRefresh),
}
//Perform an API request
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
//Success
return true;
},
/**
* Empty conversations cache
*

View File

@ -119,6 +119,14 @@ ComunicWeb.components.conversations.service = {
}
//Perform a request on the interface
ComunicWeb.components.conversations.interface.refreshConversations(
newConversations,
conversationsToRefresh,
function(result){
//Call callback function
ComunicWeb.components.conversations.service.callback(result);
}
);
//Success
return true;