Close ring screen if user respond to call on another client

This commit is contained in:
Pierre HUBERT 2019-02-23 18:27:31 +01:00
parent c819aaf716
commit be0306b309
3 changed files with 40 additions and 6 deletions

View File

@ -213,7 +213,12 @@ ComunicWeb.components.calls.controller = {
//Refuse the call if everyone has left it
if(ComunicWeb.components.calls.utils.hasEveryoneLeft(info))
ringScreenInfo.respond(false);
ringScreenInfo.respond(false);
//Close ring screen if user responded to the call on another Comunic client
if(ComunicWeb.components.calls.utils.getCurrentUserState(info) != "unknown")
ringScreenInfo.close();
});
}, 2000);

View File

@ -71,20 +71,26 @@ ComunicWeb.components.calls.ringScreen = {
innerHTML: "Accept"
});
var close = function(){
ComunicWeb.components.calls.ringScreen._song.stop();
//Remove elem
emptyElem(callContainer);
callContainer.remove();
}
var hasResponded = false;
var respond = function(accept){
ComunicWeb.components.calls.ringScreen._song.stop();
close();
if(hasResponded)
return;
hasResponded = true;
callback(accept);
//Remove elem
emptyElem(callContainer);
callContainer.remove();
}
rejectButton.addEventListener("click", function() {
@ -102,6 +108,12 @@ ComunicWeb.components.calls.ringScreen = {
return {
/**
* A function to close the current ringscreen, without
* calling callback
*/
close: close,
/**
* A function to programmatically respond to call
*/

View File

@ -22,6 +22,23 @@ ComunicWeb.components.calls.utils = {
return allDisconnected;
},
/**
* Get the current user response to a call
*
* @param {Call} call Current call information
* @return The response of the current user to the call
*/
getCurrentUserState: function(call){
var userstate = undefined;
call.members.forEach(function(member){
if(member.userID == userID())
userstate = member.status
});
return userstate;
}
};