From 1a3117a6031604cdc401cdc62588dd82654ea4c1 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 26 Jan 2019 15:49:08 +0100 Subject: [PATCH] Created calls utilities --- assets/js/common/functionsSchema.js | 9 +++++++- assets/js/components/calls/callWindow.js | 6 +----- assets/js/components/calls/utils.js | 27 ++++++++++++++++++++++++ system/config/dev.config.php | 1 + 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 assets/js/components/calls/utils.js diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 7bf557f7..6611b1eb 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -1194,7 +1194,14 @@ var ComunicWeb = { */ ringScreen: { //TODO : implement - } + }, + + /** + * Calls utilities + */ + utils: { + //TODO : implement + }, }, /** diff --git a/assets/js/components/calls/callWindow.js b/assets/js/components/calls/callWindow.js index 39ccb1a3..020aa9b4 100644 --- a/assets/js/components/calls/callWindow.js +++ b/assets/js/components/calls/callWindow.js @@ -593,11 +593,7 @@ ComunicWeb.components.calls.callWindow = { return; //Check if all other members rejected call - var allDisconnected = true; - call.info.members.forEach(function(member){ - if(member.status != "rejected" && member.status != "hang_up" && member.userID != userID()) - allDisconnected = false; - }); + var allDisconnected = ComunicWeb.components.calls.utils.hasEveryoneLeft(call.info); //Check if all call peer rejected the call if(allDisconnected){ diff --git a/assets/js/components/calls/utils.js b/assets/js/components/calls/utils.js new file mode 100644 index 00000000..b10ae22b --- /dev/null +++ b/assets/js/components/calls/utils.js @@ -0,0 +1,27 @@ +/** + * Calls utilities + * + * @author Pierre HUBERT + */ + +ComunicWeb.components.calls.utils = { + + /** + * Check out whether all the members of a conversation stop to follow it, + * except the current user + * + * @param {Object} info Information about the conversation to analyze + */ + hasEveryoneLeft: function(info){ + + var allDisconnected = true; + info.members.forEach(function(member){ + if(member.status != "rejected" && member.status != "hang_up" && member.userID != userID()) + allDisconnected = false; + }); + + return allDisconnected; + + } + +}; \ No newline at end of file diff --git a/system/config/dev.config.php b/system/config/dev.config.php index f02d6371..a208003a 100644 --- a/system/config/dev.config.php +++ b/system/config/dev.config.php @@ -453,6 +453,7 @@ class Dev { "js/components/calls/currentList.js", "js/components/calls/userMedia.js", "js/components/calls/ringScreen.js", + "js/components/calls/utils.js", //Pacman component (easter egg) "js/components/pacman.js",