Can respond to calls

This commit is contained in:
2019-01-25 09:43:19 +01:00
parent 118cfeee41
commit 9eab6c7e2e
4 changed files with 143 additions and 6 deletions

View File

@ -25,14 +25,19 @@ ComunicWeb.components.notifications.interface = {
/**
* Get the number of unread news such as notifications or conversations
*
* @param {boolean} get_calls Get the number of pending calls
* @param {function} callback
*/
getAllUnread: function(callback){
getAllUnread: function(get_calls, callback){
//Perform API request
var apiURI = "notifications/count_all_news";
var params = {};
//Check if we have to get the number of pending calls
if(get_calls)
params.include_calls = true;
//Perform the request
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);

View File

@ -35,7 +35,8 @@ ComunicWeb.components.notifications.service = {
//Get the number of notifications from the API
ComunicWeb.components.notifications.interface.getAllUnread(function(response){
ComunicWeb.components.notifications.interface.getAllUnread(
ComunicWeb.components.calls.controller.isAvailable(), function(response){
//Continue in case of success
if(response.error)
@ -76,6 +77,11 @@ ComunicWeb.components.notifications.service = {
ComunicWeb.components.notifications.song.play();
ComunicWeb.components.notifications.service.last_notifs_number = total_number_notifs;
//Process the number of calls if possible
if(response.calls && response.calls > 0)
ComunicWeb.components.calls.controller.newCallsAvailable(response.calls);
});
}, 2000);