瀏覽代碼

Reduce duplication

master
Lyubo Marinov 7 年之前
父節點
當前提交
ad497fed7c

+ 4
- 3
react/features/base/jwt/components/CalleeInfo.js 查看文件

20
 type Props = {
20
 type Props = {
21
 
21
 
22
     /**
22
     /**
23
-     * Object containing the callee's information.
23
+     * The callee's information such as avatar and display name.
24
      */
24
      */
25
     _callee: Object
25
     _callee: Object
26
-}
26
+};
27
 
27
 
28
 /**
28
 /**
29
  * The type of the React {@code Component} state of {@link CalleeInfo}.
29
  * The type of the React {@code Component} state of {@link CalleeInfo}.
57
      * @type {boolean}
57
      * @type {boolean}
58
      */
58
      */
59
     ringing: boolean
59
     ringing: boolean
60
-}
60
+};
61
 
61
 
62
 /**
62
 /**
63
  * Implements a React {@link Component} which depicts the establishment of a
63
  * Implements a React {@link Component} which depicts the establishment of a
335
 function _mapStateToProps(state) {
335
 function _mapStateToProps(state) {
336
     return {
336
     return {
337
         /**
337
         /**
338
+         * The callee's information such as avatar and display name.
338
          *
339
          *
339
          * @private
340
          * @private
340
          * @type {Object}
341
          * @type {Object}

+ 64
- 0
react/features/base/jwt/components/CalleeInfoContainer.js 查看文件

1
+// @flow
2
+
3
+import React, { Component } from 'react';
4
+import { connect } from 'react-redux';
5
+
6
+import CalleeInfo from './CalleeInfo';
7
+
8
+/**
9
+ * The type of the React {@code Component} props of {@link Conference}.
10
+ */
11
+type Props = {
12
+
13
+    /**
14
+     * The indicator which determines whether {@code CalleeInfo} is to be
15
+     * rendered.
16
+     *
17
+     * @private
18
+     */
19
+    _calleeInfoVisible: boolean
20
+};
21
+
22
+/**
23
+ * Implements a React {@link Component} which depicts the establishment of a
24
+ * call with a specific remote callee if there is such a remote callee.
25
+ *
26
+ * @extends Component
27
+ */
28
+class CalleeInfoContainer extends Component<Props> {
29
+    /**
30
+     * Implements React's {@link Component#render()}.
31
+     *
32
+     * @inheritdoc
33
+     * @returns {ReactElement}
34
+     */
35
+    render() {
36
+        return this.props._calleeInfoVisible ? <CalleeInfo /> : null;
37
+    }
38
+}
39
+
40
+/**
41
+ * Maps parts of the redux state to {@link CalleeInfoContainer} (React
42
+ * {@code Component}) props.
43
+ *
44
+ * @param {Object} state - The redux state of which parts are to be mapped to
45
+ * {@code CalleeInfoContainer} props.
46
+ * @private
47
+ * @returns {{
48
+ *     _calleeInfoVisible: boolean
49
+ * }}
50
+ */
51
+function _mapStateToProps(state: Object): Object {
52
+    return {
53
+        /**
54
+         * The indicator which determines whether {@code CalleeInfo} is to be
55
+         * rendered.
56
+         *
57
+         * @private
58
+         * @type {boolean}
59
+         */
60
+        _calleeInfoVisible: state['features/base/jwt'].calleeInfoVisible
61
+    };
62
+}
63
+
64
+export default connect(_mapStateToProps)(CalleeInfoContainer);

+ 1
- 0
react/features/base/jwt/components/index.js 查看文件

1
 export { default as CalleeInfo } from './CalleeInfo';
1
 export { default as CalleeInfo } from './CalleeInfo';
2
+export { default as CalleeInfoContainer } from './CalleeInfoContainer';

+ 3
- 17
react/features/conference/components/Conference.native.js 查看文件

9
 import { appNavigate } from '../../app';
9
 import { appNavigate } from '../../app';
10
 import { connect, disconnect } from '../../base/connection';
10
 import { connect, disconnect } from '../../base/connection';
11
 import { DialogContainer } from '../../base/dialog';
11
 import { DialogContainer } from '../../base/dialog';
12
-import { CalleeInfo } from '../../base/jwt';
12
+import { CalleeInfoContainer } from '../../base/jwt';
13
 import { Container, LoadingIndicator } from '../../base/react';
13
 import { Container, LoadingIndicator } from '../../base/react';
14
 import { createDesiredLocalTracks } from '../../base/tracks';
14
 import { createDesiredLocalTracks } from '../../base/tracks';
15
 import { Filmstrip } from '../../filmstrip';
15
 import { Filmstrip } from '../../filmstrip';
16
 import { LargeVideo } from '../../large-video';
16
 import { LargeVideo } from '../../large-video';
17
 import { setToolboxVisible, Toolbox } from '../../toolbox';
17
 import { setToolboxVisible, Toolbox } from '../../toolbox';
18
 
18
 
19
-import { abstractMapStateToProps } from '../functions';
20
-
21
 import styles from './styles';
19
 import styles from './styles';
22
 
20
 
23
 /**
21
 /**
33
  */
31
  */
34
 type Props = {
32
 type Props = {
35
 
33
 
36
-    /**
37
-     * The indication which determines if the {@code CalleeInfo} component
38
-     * should be shown or not.
39
-     *
40
-     * @private
41
-     */
42
-    _calleeInfoVisible: boolean,
43
-
44
     /**
34
     /**
45
      * The indicator which determines that we are still connecting to the
35
      * The indicator which determines that we are still connecting to the
46
      * conference which includes establishing the XMPP connection and then
36
      * conference which includes establishing the XMPP connection and then
202
 
192
 
203
                 {/*
193
                 {/*
204
                   * If there is a ringing call, show the callee's info.
194
                   * If there is a ringing call, show the callee's info.
205
-                  */
206
-                    this.props._calleeInfoVisible
207
-                        && <CalleeInfo />
208
-                }
195
+                  */}
196
+                <CalleeInfoContainer />
209
 
197
 
210
                 {/*
198
                 {/*
211
                   * The activity/loading indicator goes above everything, except
199
                   * The activity/loading indicator goes above everything, except
393
         = connecting || (connection && (joining || (!conference && !leaving)));
381
         = connecting || (connection && (joining || (!conference && !leaving)));
394
 
382
 
395
     return {
383
     return {
396
-        ...abstractMapStateToProps(state),
397
-
398
         /**
384
         /**
399
          * The indicator which determines that we are still connecting to the
385
          * The indicator which determines that we are still connecting to the
400
          * conference which includes establishing the XMPP connection and then
386
          * conference which includes establishing the XMPP connection and then

+ 2
- 14
react/features/conference/components/Conference.web.js 查看文件

6
 
6
 
7
 import { connect, disconnect } from '../../base/connection';
7
 import { connect, disconnect } from '../../base/connection';
8
 import { DialogContainer } from '../../base/dialog';
8
 import { DialogContainer } from '../../base/dialog';
9
-import { CalleeInfo } from '../../base/jwt';
9
+import { CalleeInfoContainer } from '../../base/jwt';
10
 import { Filmstrip } from '../../filmstrip';
10
 import { Filmstrip } from '../../filmstrip';
11
 import { LargeVideo } from '../../large-video';
11
 import { LargeVideo } from '../../large-video';
12
 import { NotificationsContainer } from '../../notifications';
12
 import { NotificationsContainer } from '../../notifications';
13
 import { showToolbox, Toolbox } from '../../toolbox';
13
 import { showToolbox, Toolbox } from '../../toolbox';
14
 import { HideNotificationBarStyle } from '../../unsupported-browser';
14
 import { HideNotificationBarStyle } from '../../unsupported-browser';
15
 
15
 
16
-import { abstractMapStateToProps } from '../functions';
17
-
18
 declare var APP: Object;
16
 declare var APP: Object;
19
 declare var interfaceConfig: Object;
17
 declare var interfaceConfig: Object;
20
 
18
 
23
  */
21
  */
24
 type Props = {
22
 type Props = {
25
 
23
 
26
-    /**
27
-     * Whether or not the callee's info for a ringing call should be shown
28
-     * or not.
29
-     */
30
-    _calleeInfoVisible: boolean,
31
-
32
     /**
24
     /**
33
      * Whether or not the current local user is recording the conference.
25
      * Whether or not the current local user is recording the conference.
34
      */
26
      */
122
                 <DialogContainer />
114
                 <DialogContainer />
123
                 <NotificationsContainer />
115
                 <NotificationsContainer />
124
 
116
 
125
-                { this.props._calleeInfoVisible
126
-                    && <CalleeInfo />
127
-                }
117
+                <CalleeInfoContainer />
128
 
118
 
129
                 {/*
119
                 {/*
130
                   * Temasys automatically injects a notification bar, if
120
                   * Temasys automatically injects a notification bar, if
161
  */
151
  */
162
 function _mapStateToProps(state) {
152
 function _mapStateToProps(state) {
163
     return {
153
     return {
164
-        ...abstractMapStateToProps(state),
165
-
166
         /**
154
         /**
167
          * Indicates if the current user is recording the conference, ie, they
155
          * Indicates if the current user is recording the conference, ie, they
168
          * are a recorder.
156
          * are a recorder.

+ 0
- 25
react/features/conference/functions.js 查看文件

1
-// @flow
2
-
3
-/**
4
- * Maps parts of the redux state to {@link Toolbox} (React {@code Component})
5
- * props.
6
- *
7
- * @param {Object} state - The redux state of which parts are to be mapped to
8
- * {@code Conference} props.
9
- * @protected
10
- * @returns {{
11
- *     _calleeInfoVisible: boolean
12
- * }}
13
- */
14
-export function abstractMapStateToProps(state: Object): Object {
15
-    return {
16
-        /**
17
-         * The indication which determines if the {@code CalleeInfo} component
18
-         * should be shown or not.
19
-         *
20
-         * @private
21
-         * @type {boolean}
22
-         */
23
-        _calleeInfoVisible: state['features/base/jwt'].calleeInfoVisible
24
-    };
25
-}

Loading…
取消
儲存