From 09d63d38ab7fd5804650b5a04e818d22906af71b Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Wed, 18 Jan 2017 13:24:30 -0600 Subject: [PATCH] fix(iframe_api): prevents multiple execution of listeners per event --- modules/API/external/external_api.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index bfd84930f..9535131ee 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -173,6 +173,9 @@ function JitsiMeetExternalAPI(domain, room_name, width, height, parentNode, this.eventHandlers = {}; + // Map<{string} event_name, {boolean} postis_listener_added> + this.postisListeners = {}; + this.numberOfParticipants = 1; this._setupListeners(); @@ -328,12 +331,14 @@ JitsiMeetExternalAPI.prototype.addEventListener = function(event, listener) { } // We cannot remove listeners from postis that's why we are handling the // callback that way. - if(!(event in this.eventHandlers)) + if(!this.postisListeners[event]) { this.postis.listen(events[event], function(data) { if((event in this.eventHandlers) && typeof this.eventHandlers[event] === "function") this.eventHandlers[event].call(null, data); }.bind(this)); + this.postisListeners[event] = true; + } this.eventHandlers[event] = listener; changeEventStatus(this.postis, event, true); };