diff --git a/js/app.js b/js/app.js index 72066ddbf12..6a68846adc1 100644 --- a/js/app.js +++ b/js/app.js @@ -328,7 +328,6 @@ self.stopListening(self.activeRoom, 'change:displayName'); self.stopListening(self.activeRoom, 'change:participantFlags'); - var participants; if (OC.getCurrentUser().uid) { roomChannel.trigger('active', token); @@ -337,15 +336,6 @@ self.activeRoom = room; } }); - participants = self.activeRoom.get('participants'); - } else { - // The public page supports only a single room, so the - // active room is already the room for the given token. - participants = self.activeRoom.get('participants'); - } - // Disable video when entering a room with more than 5 participants. - if (participants && Object.keys(participants).length > 5) { - self.disableVideo(); } self._emptyContentView.setActiveRoom(self.activeRoom); @@ -605,6 +595,15 @@ } }.bind(this)); + this.signaling.on('joinCall', function() { + // Disable video when joining a call in a room with more than 5 + // participants. + var participants = this.activeRoom.get('participants'); + if (participants && Object.keys(participants).length > 5) { + this.disableVideo(); + } + }.bind(this)); + $(window).unload(function () { this.connection.leaveCurrentRoom(); this.signaling.disconnect(); @@ -792,9 +791,9 @@ localVideo.hide(); }, disableVideo: function() { - this._mediaControlsView.disableVideo(); - // Always hide the video, even if "disableVideo" returned "false". - this.hideVideo(); + if (this._mediaControlsView.disableVideo()) { + this.hideVideo(); + } }, // Called from webrtc.js disableScreensharingButton: function() { diff --git a/js/embedded.js b/js/embedded.js index 3d4972f7c47..795a0eeb8db 100644 --- a/js/embedded.js +++ b/js/embedded.js @@ -83,7 +83,6 @@ .then(function() { self.stopListening(self.activeRoom, 'change:participantFlags'); - var participants; if (OC.getCurrentUser().uid) { roomChannel.trigger('active', token); @@ -92,11 +91,6 @@ self.activeRoom = room; } }); - participants = self.activeRoom.get('participants'); - } - // Disable video when entering a room with more than 5 participants. - if (participants && Object.keys(participants).length > 5) { - self.disableVideo(); } }); }, @@ -127,6 +121,15 @@ this.signaling = OCA.Talk.Signaling.createConnection(); this.connection = new OCA.Talk.Connection(this); + this.signaling.on('joinCall', function() { + // Disable video when joining a call in a room with more than 5 + // participants. + var participants = this.activeRoom.get('participants'); + if (participants && Object.keys(participants).length > 5) { + this.disableVideo(); + } + }.bind(this)); + $(window).unload(function () { this.connection.leaveCurrentRoom(); this.signaling.disconnect(); @@ -234,9 +237,9 @@ localVideo.hide(); }, disableVideo: function() { - this._mediaControlsView.disableVideo(); - // Always hide the video, even if "disableVideo" returned "false". - this.hideVideo(); + if (this._mediaControlsView.disableVideo()) { + this.hideVideo(); + } }, // Called from webrtc.js disableScreensharingButton: function() {