浏览代码

Turn TranscribingLabel a self-containing component

master
Bettenbuk Zoltan 7 年前
父节点
当前提交
d604cdfe27

+ 3
- 14
react/features/large-video/components/AbstractLabels.js 查看文件

@@ -20,11 +20,6 @@ export type Props = {
20 20
      */
21 21
     _filmstripVisible: boolean,
22 22
 
23
-    /**
24
-     * Whether the video quality label should be displayed.
25
-     */
26
-    _showTranscribingLabel: boolean,
27
-
28 23
     /**
29 24
      * Whether the video quality label should be displayed.
30 25
      */
@@ -71,13 +66,9 @@ export default class AbstractLabels<P: Props, S> extends Component<P, S> {
71 66
      * @returns {React$Element}
72 67
      */
73 68
     _renderTranscribingLabel() {
74
-        if (this.props._showTranscribingLabel) {
75
-            return (
76
-                <TranscribingLabel />
77
-            );
78
-        }
79
-
80
-        return null;
69
+        return (
70
+            <TranscribingLabel />
71
+        );
81 72
     }
82 73
 
83 74
     /**
@@ -101,14 +92,12 @@ export default class AbstractLabels<P: Props, S> extends Component<P, S> {
101 92
  * @private
102 93
  * @returns {{
103 94
  *     _filmstripVisible: boolean,
104
- *     _showTranscribingLabel: boolean,
105 95
  *     _showVideoQualityLabel: boolean
106 96
  * }}
107 97
  */
108 98
 export function _abstractMapStateToProps(state: Object) {
109 99
     return {
110 100
         _filmstripVisible: isFilmstripVisible(state),
111
-        _showTranscribingLabel: state['features/transcribing'].isTranscribing,
112 101
         _showVideoQualityLabel: !shouldDisplayTileView(state)
113 102
     };
114 103
 }

+ 21
- 0
react/features/transcribing/components/AbstractTranscribingLabel.js 查看文件

@@ -5,8 +5,29 @@
5 5
  */
6 6
 export type Props = {
7 7
 
8
+    /**
9
+     * True if the label needs to be rendered, false otherwise.
10
+     */
11
+    _showLabel: boolean,
12
+
8 13
     /**
9 14
      * Invoked to obtain translated strings.
10 15
      */
11 16
     t: Function
12 17
 };
18
+
19
+/**
20
+ * Maps (parts of) the redux state to the associated props of the
21
+ * {@link AbstractTranscribingLabel} {@code Component}.
22
+ *
23
+ * @param {Object} state - The redux state.
24
+ * @private
25
+ * @returns {{
26
+ *     _showLabel: boolean
27
+ * }}
28
+ */
29
+export function _mapStateToProps(state: Object) {
30
+    return {
31
+        _showLabel: state['features/transcribing'].isTranscribing
32
+    };
33
+}

+ 7
- 2
react/features/transcribing/components/TranscribingLabel.native.js 查看文件

@@ -1,11 +1,12 @@
1 1
 // @flow
2 2
 
3 3
 import React, { Component } from 'react';
4
+import { connect } from 'react-redux';
4 5
 
5 6
 import { translate } from '../../base/i18n';
6 7
 import { CircularLabel } from '../../base/label';
7 8
 
8
-import { type Props } from './AbstractTranscribingLabel';
9
+import { _mapStateToProps, type Props } from './AbstractTranscribingLabel';
9 10
 
10 11
 /**
11 12
  * React {@code Component} for displaying a label when a transcriber is in the
@@ -21,6 +22,10 @@ class TranscribingLabel extends Component<Props> {
21 22
      * @inheritdoc
22 23
      */
23 24
     render() {
25
+        if (!this.props._showLabel) {
26
+            return null;
27
+        }
28
+
24 29
         return (
25 30
             <CircularLabel
26 31
                 label = { this.props.t('transcribing.tr') } />
@@ -28,4 +33,4 @@ class TranscribingLabel extends Component<Props> {
28 33
     }
29 34
 }
30 35
 
31
-export default translate(TranscribingLabel);
36
+export default translate(connect(_mapStateToProps)(TranscribingLabel));

+ 7
- 2
react/features/transcribing/components/TranscribingLabel.web.js 查看文件

@@ -2,11 +2,12 @@
2 2
 
3 3
 import Tooltip from '@atlaskit/tooltip';
4 4
 import React, { Component } from 'react';
5
+import { connect } from 'react-redux';
5 6
 
6 7
 import { translate } from '../../base/i18n';
7 8
 import { CircularLabel } from '../../base/label';
8 9
 
9
-import { type Props } from './AbstractTranscribingLabel';
10
+import { _mapStateToProps, type Props } from './AbstractTranscribingLabel';
10 11
 
11 12
 /**
12 13
  * React {@code Component} for displaying a label when a transcriber is in the
@@ -23,6 +24,10 @@ class TranscribingLabel extends Component<Props> {
23 24
      * @returns {ReactElement}
24 25
      */
25 26
     render() {
27
+        if (!this.props._showLabel) {
28
+            return null;
29
+        }
30
+
26 31
         return (
27 32
             <Tooltip
28 33
                 content = { this.props.t('transcribing.labelToolTip') }
@@ -36,4 +41,4 @@ class TranscribingLabel extends Component<Props> {
36 41
 
37 42
 }
38 43
 
39
-export default translate(TranscribingLabel);
44
+export default translate(connect(_mapStateToProps)(TranscribingLabel));

正在加载...
取消
保存