From 9ca7ca951598c2f20fcac530b3124a1a879b8bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 20 Apr 2018 13:56:24 +0200 Subject: [PATCH] feat(toolbox): move visibleButtons to redux Technically we still depend on interfaceConfig, but this paves the way for when that is no longer the case. --- .../toolbox/components/Toolbox.web.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/react/features/toolbox/components/Toolbox.web.js b/react/features/toolbox/components/Toolbox.web.js index 130208b56..def0d6705 100644 --- a/react/features/toolbox/components/Toolbox.web.js +++ b/react/features/toolbox/components/Toolbox.web.js @@ -158,6 +158,11 @@ type Props = { */ _visible: boolean, + /** + * Set with the buttons which this Toolbox should display. + */ + _visibleButtons: Set, + /** * Invoked to active other features of the app. */ @@ -178,8 +183,6 @@ declare var interfaceConfig: Object; * @extends Component */ class Toolbox extends Component { - _visibleButtons: Object; - /** * Initializes a new {@code Toolbox} instance. * @@ -189,8 +192,6 @@ class Toolbox extends Component { constructor(props: Props) { super(props); - this._visibleButtons = new Set(interfaceConfig.TOOLBAR_BUTTONS); - // Bind event handlers so they are only bound once per instance. this._onMouseOut = this._onMouseOut.bind(this); this._onMouseOver = this._onMouseOver.bind(this); @@ -315,10 +316,11 @@ class Toolbox extends Component { _overflowMenuVisible, _raisedHand, _visible, + _visibleButtons, t } = this.props; const rootClassNames = `new-toolbox ${_visible ? 'visible' : ''} ${ - this._visibleButtons.size ? '' : 'no-buttons'}`; + _visibleButtons.size ? '' : 'no-buttons'}`; const overflowMenuContent = this._renderOverflowMenuContent(); const overflowHasItems = Boolean(overflowMenuContent.filter( child => child).length); @@ -1030,7 +1032,7 @@ class Toolbox extends Component { * @returns {boolean} True if the button should be displayed. */ _shouldShowButton(buttonName) { - return this._visibleButtons.has(buttonName); + return this.props._visibleButtons.has(buttonName); } } @@ -1093,7 +1095,11 @@ function _mapStateToProps(state) { _sharingVideo: sharedVideoStatus === 'playing' || sharedVideoStatus === 'start' || sharedVideoStatus === 'pause', - _visible: Boolean(timeoutID || visible || alwaysVisible) + _visible: Boolean(timeoutID || visible || alwaysVisible), + + // XXX: We are not currently using state here, but in the future, when + // interfaceConfig is part of redux we will. + _visibleButtons: new Set(interfaceConfig.TOOLBAR_BUTTONS) }; }