From 882781e216564d4b8c5d06c6b5e59d3f2be5bf8b Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 3 Jun 2017 16:39:47 +0200 Subject: [PATCH] Improved intervals --- assets/js/components/friends/friendsBar.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/assets/js/components/friends/friendsBar.js b/assets/js/components/friends/friendsBar.js index 267b093c..ff265df4 100644 --- a/assets/js/components/friends/friendsBar.js +++ b/assets/js/components/friends/friendsBar.js @@ -61,12 +61,15 @@ ComunicWeb.components.friends.bar = { //Refresh friends list this.refresh(listFriendsElem); - //Make the friend bar automaticaly refreshed (if the interval wasn't already defined) - if(!this.refreshInterval) - this.refreshInterval = setInterval(function(){ - if(byId("friendsList")) - ComunicWeb.components.friends.bar.refresh(listFriendsElem); - }, 1000); + //Remove previously existing interval + if(this.refreshInterval) + clearInterval(this.refreshInterval); + + //Make the friend bar automaticaly refreshed + this.refreshInterval = setInterval(function(){ + if(byId("friendsList")) + ComunicWeb.components.friends.bar.refresh(listFriendsElem); + }, 15000); //Success return true;