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

@ -105,7 +105,7 @@ ComunicWeb.common.network = {
networkErrorMessage.id = "networkErrorMessage"; networkErrorMessage.id = "networkErrorMessage";
//Create a callout element within it //Create a callout element within it
var errorName = "<i class='fa fa-warning'></i> "+"Network error"; var errorName = "<i class='fa fa-warning'></i> "+" Network error";
var errorMessage = "It seems that there is a network error, and Comunic can't access to the Internet anymore... Please check your internet connexion..."; var errorMessage = "It seems that there is a network error, and Comunic can't access to the Internet anymore... Please check your internet connexion...";
var errorCallout = ComunicWeb.common.messages.createCalloutElem(errorName, errorMessage, "danger"); var errorCallout = ComunicWeb.common.messages.createCalloutElem(errorName, errorMessage, "danger");
networkErrorMessage.appendChild(errorCallout) networkErrorMessage.appendChild(errorCallout)

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 * Empty conversations cache
* *

View File

@ -119,6 +119,14 @@ ComunicWeb.components.conversations.service = {
} }
//Perform a request on the interface //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 //Success
return true; return true;