From 246ab88a3e9b265c677f958660423b9e6185134d Mon Sep 17 00:00:00 2001 From: damencho Date: Tue, 23 Aug 2016 18:37:41 -0500 Subject: [PATCH] Fixes muting particular remote participant. There was a bug that the handlers for menuItem for mute and kick are added for all remote participants. When clicked multiple handlers are executed and the action will be executed for all remote participants. --- modules/UI/videolayout/RemoteVideo.js | 10 +++++++--- modules/UI/videolayout/VideoLayout.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/UI/videolayout/RemoteVideo.js b/modules/UI/videolayout/RemoteVideo.js index 62e28e4eb..52d898d20 100644 --- a/modules/UI/videolayout/RemoteVideo.js +++ b/modules/UI/videolayout/RemoteVideo.js @@ -13,6 +13,7 @@ function RemoteVideo(id, VideoLayout, emitter) { this.emitter = emitter; this.videoSpanId = `participant_${id}`; SmallVideo.call(this, VideoLayout); + this.hasRemoteVideoMenu = false; this.addRemoteVideoContainer(); this.connectionIndicator = new ConnectionIndicator(this, id); this.setDisplayName(); @@ -93,7 +94,7 @@ RemoteVideo.prototype._generatePopupContent = function () { APP.translation.translateString("videothumbnail.muted") + ""; - muteLinkItem.id = "muteLinkItem"; + muteLinkItem.id = "mutelink_" + this.id; if (this.isMuted) { muteLinkItem.innerHTML = mutedHTML; @@ -105,7 +106,7 @@ RemoteVideo.prototype._generatePopupContent = function () { } // Delegate event to the document. - $(document).on("click", ".mutelink", function(){ + $(document).on("click", "#mutelink_" + this.id, function(){ if (this.isMuted) return; @@ -130,8 +131,9 @@ RemoteVideo.prototype._generatePopupContent = function () { ejectLinkItem.className = 'ejectlink'; ejectLinkItem.innerHTML = ejectIndicator + ' ' + ejectText; + ejectLinkItem.id = "ejectlink_" + this.id; - $(document).on("click", ".ejectlink", function(){ + $(document).on("click", "#ejectlink_" + this.id, function(){ this.emitter.emit(UIEvents.USER_KICKED, this.id); this.popover.forceHide(); }.bind(this)); @@ -178,6 +180,7 @@ if (!interfaceConfig.filmStripOnly) { spanElement.appendChild(menuElement); this._initPopupMenu(this._generatePopupContent()); + this.hasRemoteVideoMenu = true; }; } else { @@ -419,6 +422,7 @@ RemoteVideo.prototype.removeRemoteVideoMenu = function() { if (menuSpan.length) { this.popover.forceHide(); menuSpan.remove(); + this.hasRemoteVideoMenu = false; } }; diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.js index 895334c7f..3cb4b48d1 100644 --- a/modules/UI/videolayout/VideoLayout.js +++ b/modules/UI/videolayout/VideoLayout.js @@ -472,7 +472,7 @@ var VideoLayout = { remoteVideo.createModeratorIndicatorElement(); } else if (isModerator) { // We are moderator, but user is not - add menu - if ($(`#remote_popupmenu_${id}`).length <= 0) { + if(!remoteVideo.hasRemoteVideoMenu) { remoteVideo.addRemoteVideoMenu(); } }