Sfoglia il codice sorgente

Reduce duplication

master
Lyubo Marinov 7 anni fa
parent
commit
ad497fed7c

+ 4
- 3
react/features/base/jwt/components/CalleeInfo.js Vedi File

@@ -20,10 +20,10 @@ declare var interfaceConfig: Object;
20 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 25
     _callee: Object
26
-}
26
+};
27 27
 
28 28
 /**
29 29
  * The type of the React {@code Component} state of {@link CalleeInfo}.
@@ -57,7 +57,7 @@ type State = {
57 57
      * @type {boolean}
58 58
      */
59 59
     ringing: boolean
60
-}
60
+};
61 61
 
62 62
 /**
63 63
  * Implements a React {@link Component} which depicts the establishment of a
@@ -335,6 +335,7 @@ class CalleeInfo extends Component<Props, State> {
335 335
 function _mapStateToProps(state) {
336 336
     return {
337 337
         /**
338
+         * The callee's information such as avatar and display name.
338 339
          *
339 340
          * @private
340 341
          * @type {Object}

+ 64
- 0
react/features/base/jwt/components/CalleeInfoContainer.js Vedi File

@@ -0,0 +1,64 @@
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 Vedi File

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

+ 3
- 17
react/features/conference/components/Conference.native.js Vedi File

@@ -9,15 +9,13 @@ import { connect as reactReduxConnect } from 'react-redux';
9 9
 import { appNavigate } from '../../app';
10 10
 import { connect, disconnect } from '../../base/connection';
11 11
 import { DialogContainer } from '../../base/dialog';
12
-import { CalleeInfo } from '../../base/jwt';
12
+import { CalleeInfoContainer } from '../../base/jwt';
13 13
 import { Container, LoadingIndicator } from '../../base/react';
14 14
 import { createDesiredLocalTracks } from '../../base/tracks';
15 15
 import { Filmstrip } from '../../filmstrip';
16 16
 import { LargeVideo } from '../../large-video';
17 17
 import { setToolboxVisible, Toolbox } from '../../toolbox';
18 18
 
19
-import { abstractMapStateToProps } from '../functions';
20
-
21 19
 import styles from './styles';
22 20
 
23 21
 /**
@@ -33,14 +31,6 @@ const _TOOLBOX_TIMEOUT_MS = 5000;
33 31
  */
34 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 35
      * The indicator which determines that we are still connecting to the
46 36
      * conference which includes establishing the XMPP connection and then
@@ -202,10 +192,8 @@ class Conference extends Component<Props> {
202 192
 
203 193
                 {/*
204 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 199
                   * The activity/loading indicator goes above everything, except
@@ -393,8 +381,6 @@ function _mapStateToProps(state) {
393 381
         = connecting || (connection && (joining || (!conference && !leaving)));
394 382
 
395 383
     return {
396
-        ...abstractMapStateToProps(state),
397
-
398 384
         /**
399 385
          * The indicator which determines that we are still connecting to the
400 386
          * conference which includes establishing the XMPP connection and then

+ 2
- 14
react/features/conference/components/Conference.web.js Vedi File

@@ -6,15 +6,13 @@ import { connect as reactReduxConnect } from 'react-redux';
6 6
 
7 7
 import { connect, disconnect } from '../../base/connection';
8 8
 import { DialogContainer } from '../../base/dialog';
9
-import { CalleeInfo } from '../../base/jwt';
9
+import { CalleeInfoContainer } from '../../base/jwt';
10 10
 import { Filmstrip } from '../../filmstrip';
11 11
 import { LargeVideo } from '../../large-video';
12 12
 import { NotificationsContainer } from '../../notifications';
13 13
 import { showToolbox, Toolbox } from '../../toolbox';
14 14
 import { HideNotificationBarStyle } from '../../unsupported-browser';
15 15
 
16
-import { abstractMapStateToProps } from '../functions';
17
-
18 16
 declare var APP: Object;
19 17
 declare var interfaceConfig: Object;
20 18
 
@@ -23,12 +21,6 @@ declare var interfaceConfig: Object;
23 21
  */
24 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 25
      * Whether or not the current local user is recording the conference.
34 26
      */
@@ -122,9 +114,7 @@ class Conference extends Component<Props> {
122 114
                 <DialogContainer />
123 115
                 <NotificationsContainer />
124 116
 
125
-                { this.props._calleeInfoVisible
126
-                    && <CalleeInfo />
127
-                }
117
+                <CalleeInfoContainer />
128 118
 
129 119
                 {/*
130 120
                   * Temasys automatically injects a notification bar, if
@@ -161,8 +151,6 @@ class Conference extends Component<Props> {
161 151
  */
162 152
 function _mapStateToProps(state) {
163 153
     return {
164
-        ...abstractMapStateToProps(state),
165
-
166 154
         /**
167 155
          * Indicates if the current user is recording the conference, ie, they
168 156
          * are a recorder.

+ 0
- 25
react/features/conference/functions.js Vedi File

@@ -1,25 +0,0 @@
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…
Annulla
Salva