From bbaaf3a5c25b74c020442d78eb2c48cbe505bce6 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 23 Feb 2019 18:36:40 +0100 Subject: [PATCH] Only allow one window per conversation --- assets/js/components/calls/controller.js | 4 ++++ assets/js/components/calls/currentList.js | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/assets/js/components/calls/controller.js b/assets/js/components/calls/controller.js index 95dee3f3..9a19ba5b 100644 --- a/assets/js/components/calls/controller.js +++ b/assets/js/components/calls/controller.js @@ -142,6 +142,10 @@ ComunicWeb.components.calls.controller = { */ open: function(call){ + //Check if the call is already in the list of calls + if(ComunicWeb.components.calls.currentList.isCallInList(call.id)) + return; + //Add the call to the list of opened calls ComunicWeb.components.calls.currentList.addCallToList(call.id); diff --git a/assets/js/components/calls/currentList.js b/assets/js/components/calls/currentList.js index 9f4863a4..5bdf7842 100644 --- a/assets/js/components/calls/currentList.js +++ b/assets/js/components/calls/currentList.js @@ -27,6 +27,15 @@ ComunicWeb.components.calls.currentList = { return string.split(","); }, + /** + * Check if a call ID is in the list of opened calls + * + * @param {Number} id The ID of the call to check + */ + isCallInList: function(id){ + return this.getCurrentCallsList().includes(""+id); + }, + /** * Save a new list of calls *