mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Close ring screen if user respond to call on another client
This commit is contained in:
		@@ -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);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
			 */
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
		Reference in New Issue
	
	Block a user