Extract isToolboxVisible function

This commit is contained in:
Bettenbuk Zoltan 2019-01-30 18:19:40 +01:00 committed by Saúl Ibarra Corretgé
parent d7d9bc4eeb
commit 045a2d6aca
4 changed files with 27 additions and 4 deletions

View File

@ -7,8 +7,12 @@ import { connect } from 'react-redux';
import { Container } from '../../../base/react';
import { ChatButton } from '../../../chat';
import { isToolboxVisible } from '../../functions';
import AudioMuteButton from '../AudioMuteButton';
import HangupButton from '../HangupButton';
import VideoMuteButton from '../VideoMuteButton';
import OverflowMenuButton from './OverflowMenuButton';
import styles, {
chatButtonOverride,
@ -16,7 +20,6 @@ import styles, {
toolbarButtonStyles,
toolbarToggledButtonStyles
} from './styles';
import VideoMuteButton from '../VideoMuteButton';
/**
* The number of buttons other than {@link HangupButton} to render in
@ -262,10 +265,8 @@ class Toolbox extends Component<Props, State> {
* }}
*/
function _mapStateToProps(state: Object): Object {
const { alwaysVisible, enabled, visible } = state['features/toolbox'];
return {
_visible: enabled && (alwaysVisible || visible)
_visible: isToolboxVisible(state)
};
}

View File

@ -0,0 +1,17 @@
// @flow
import { toState } from '../base/redux';
/**
* Returns true if the toolbox is visible.
*
* @param {Object | Function} stateful - A function or object that can be
* resolved to Redux state by the function {@code toState}.
* @returns {boolean}
*/
export function isToolboxVisible(stateful: Object | Function) {
const { alwaysVisible, enabled, visible }
= toState(stateful)['features/toolbox'];
return enabled && (alwaysVisible || visible);
}

View File

@ -0,0 +1,3 @@
// @flow
export * from './functions.any';

View File

@ -1,5 +1,7 @@
// @flow
export * from './functions.any';
declare var interfaceConfig: Object;
/**