Browse Source

Extract isToolboxVisible function

master
Bettenbuk Zoltan 6 years ago
parent
commit
045a2d6aca

+ 5
- 4
react/features/toolbox/components/native/Toolbox.js View File

7
 import { Container } from '../../../base/react';
7
 import { Container } from '../../../base/react';
8
 import { ChatButton } from '../../../chat';
8
 import { ChatButton } from '../../../chat';
9
 
9
 
10
+import { isToolboxVisible } from '../../functions';
11
+
10
 import AudioMuteButton from '../AudioMuteButton';
12
 import AudioMuteButton from '../AudioMuteButton';
11
 import HangupButton from '../HangupButton';
13
 import HangupButton from '../HangupButton';
14
+import VideoMuteButton from '../VideoMuteButton';
15
+
12
 import OverflowMenuButton from './OverflowMenuButton';
16
 import OverflowMenuButton from './OverflowMenuButton';
13
 import styles, {
17
 import styles, {
14
     chatButtonOverride,
18
     chatButtonOverride,
16
     toolbarButtonStyles,
20
     toolbarButtonStyles,
17
     toolbarToggledButtonStyles
21
     toolbarToggledButtonStyles
18
 } from './styles';
22
 } from './styles';
19
-import VideoMuteButton from '../VideoMuteButton';
20
 
23
 
21
 /**
24
 /**
22
  * The number of buttons other than {@link HangupButton} to render in
25
  * The number of buttons other than {@link HangupButton} to render in
262
  * }}
265
  * }}
263
  */
266
  */
264
 function _mapStateToProps(state: Object): Object {
267
 function _mapStateToProps(state: Object): Object {
265
-    const { alwaysVisible, enabled, visible } = state['features/toolbox'];
266
-
267
     return {
268
     return {
268
-        _visible: enabled && (alwaysVisible || visible)
269
+        _visible: isToolboxVisible(state)
269
     };
270
     };
270
 }
271
 }
271
 
272
 

+ 17
- 0
react/features/toolbox/functions.any.js View File

1
+// @flow
2
+
3
+import { toState } from '../base/redux';
4
+
5
+/**
6
+ * Returns true if the toolbox is visible.
7
+ *
8
+ * @param {Object | Function} stateful - A function or object that can be
9
+ * resolved to Redux state by the function {@code toState}.
10
+ * @returns {boolean}
11
+ */
12
+export function isToolboxVisible(stateful: Object | Function) {
13
+    const { alwaysVisible, enabled, visible }
14
+        = toState(stateful)['features/toolbox'];
15
+
16
+    return enabled && (alwaysVisible || visible);
17
+}

+ 3
- 0
react/features/toolbox/functions.native.js View File

1
+// @flow
2
+
3
+export * from './functions.any';

+ 2
- 0
react/features/toolbox/functions.web.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
+export * from './functions.any';
4
+
3
 declare var interfaceConfig: Object;
5
 declare var interfaceConfig: Object;
4
 
6
 
5
 /**
7
 /**

Loading…
Cancel
Save