From a3bfce4c407d9c94280c9a9f5c196dbb60ec74b5 Mon Sep 17 00:00:00 2001 From: yanas Date: Fri, 1 Apr 2016 16:26:30 -0500 Subject: [PATCH] Set follow-me initial state after enable --- modules/FollowMe.js | 54 ++++++++++++++++++++++++++++++++++++++++----- modules/UI/UI.js | 8 +++++++ 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/modules/FollowMe.js b/modules/FollowMe.js index 0626d1bd0b..a4b18f8129 100644 --- a/modules/FollowMe.js +++ b/modules/FollowMe.js @@ -16,7 +16,6 @@ import UIEvents from '../service/UI/UIEvents'; import VideoLayout from './UI/videolayout/VideoLayout'; -import FilmStrip from './UI/videolayout/FilmStrip'; /** * The (name of the) command which transports the state (represented by @@ -137,6 +136,29 @@ class FollowMe { this._onFollowMeCommand.bind(this)); } + /** + * Sets the current state of all follow-me properties, which will fire a + * localPropertyChangeEvent and trigger a send of the follow-me command. + * @private + */ + _setFollowMeInitialState() { + this._filmStripToggled.bind(this, this._UI.isFilmStripVisible()); + + var pinnedId = VideoLayout.getPinnedId(); + var isPinned = false; + var smallVideo; + if (pinnedId) { + isPinned = true; + smallVideo = VideoLayout.getSmallVideo(pinnedId); + } + + this._nextOnStage(smallVideo, isPinned); + + this._sharedDocumentToggled + .bind(this, this._UI.getSharedDocumentManager().isVisible()); + + } + /** * Adds listeners for the UI states of the local participant which are * to be followed (by the remote participants). A non-moderator (very @@ -181,9 +203,10 @@ class FollowMe { * to disable it */ enableFollowMe (enable) { - this.isEnabled = enable; - if (this.isEnabled) + if (enable) { + this._setFollowMeInitialState(); this._addFollowMeListeners(); + } else this._removeFollowMeListeners(); } @@ -211,7 +234,7 @@ class FollowMe { } /** - * Changes the nextOnPage property value. + * Changes the nextOnStage property value. * * @param smallVideo the {SmallVideo} that was pinned or unpinned * @param isPinned indicates if the given {SmallVideo} was pinned or @@ -295,6 +318,13 @@ class FollowMe { this._onSharedDocumentVisible(attributes.sharedDocumentVisible); } + /** + * Process a film strip open / close event received from FOLLOW-ME + * command. + * @param filmStripVisible indicates if the film strip has been shown or + * hidden + * @private + */ _onFilmStripVisible(filmStripVisible) { if (typeof filmStripVisible !== 'undefined') { // XXX The Command(s) API doesn't preserve the types (of @@ -307,11 +337,18 @@ class FollowMe { // eventEmitter as a public field. I'm not sure at the time of this // writing whether calling UI.toggleFilmStrip() is acceptable (from // a design standpoint) either. - if (filmStripVisible !== FilmStrip.isFilmStripVisible()) + if (filmStripVisible !== this._UI.isFilmStripVisible()) this._UI.eventEmitter.emit(UIEvents.TOGGLE_FILM_STRIP); } } + /** + * Process the id received from a FOLLOW-ME command. + * @param id the identifier of the next participant to show on stage or + * undefined if we're clearing the stage (we're unpining all pined and we + * rely on dominant speaker events) + * @private + */ _onNextOnStage(id) { var clickId = null; var pin; @@ -328,6 +365,13 @@ class FollowMe { this._pinVideoThumbnailById(clickId, pin); } + /** + * Process a shared document open / close event received from FOLLOW-ME + * command. + * @param sharedDocumentVisible indicates if the shared document has been + * opened or closed + * @private + */ _onSharedDocumentVisible(sharedDocumentVisible) { if (typeof sharedDocumentVisible !== 'undefined') { // XXX The Command(s) API doesn't preserve the types (of diff --git a/modules/UI/UI.js b/modules/UI/UI.js index b993f60f78..97cdddf82b 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -627,6 +627,14 @@ UI.toggleFilmStrip = function () { self.toggleFilmStrip.apply(self, arguments); }; +/** + * Indicates if the film strip is currently visible or not. + * @returns {true} if the film strip is currently visible, otherwise + */ +UI.isFilmStripVisible = function () { + return FilmStrip.isFilmStripVisible(); +}; + /** * Toggles chat panel. */