Browse Source

[RN] Weaken the coupling between WelcomePage and AbstractWelcomePage

master
Lyubo Marinov 8 years ago
parent
commit
b304ad5808

+ 11
- 9
react/features/base/tracks/actions.js View File

@@ -17,21 +17,23 @@ import { createLocalTracksF } from './functions';
17 17
 
18 18
 /**
19 19
  * Requests the creating of the desired media type tracks. Desire is expressed
20
- * by base/media. This function will dispatch a {@code createLocalTracksA}
21
- * action for the "missing" types, that is, the ones which base/media would
22
- * like to have (unmuted tracks) but are not present yet.
20
+ * by base/media unless the function caller specifies desired media types
21
+ * explicitly and thus override base/media. Dispatches a
22
+ * {@code createLocalTracksA} action for the desired media types for which there
23
+ * are no existing tracks yet.
23 24
  *
24 25
  * @returns {Function}
25 26
  */
26
-export function createDesiredLocalTracks() {
27
+export function createDesiredLocalTracks(...desiredTypes) {
27 28
     return (dispatch, getState) => {
28 29
         const state = getState();
29
-        const desiredTypes = [];
30 30
 
31
-        state['features/base/media'].audio.muted
32
-            || desiredTypes.push(MEDIA_TYPE.AUDIO);
33
-        Boolean(state['features/base/media'].video.muted)
34
-            || desiredTypes.push(MEDIA_TYPE.VIDEO);
31
+        if (desiredTypes.length === 0) {
32
+            const { audio, video } = state['features/base/media'];
33
+
34
+            audio.muted || desiredTypes.push(MEDIA_TYPE.AUDIO);
35
+            Boolean(video.muted) || desiredTypes.push(MEDIA_TYPE.VIDEO);
36
+        }
35 37
 
36 38
         const availableTypes
37 39
             = state['features/base/tracks']

+ 2
- 5
react/features/welcome/components/WelcomePage.native.js View File

@@ -6,7 +6,7 @@ import { translate } from '../../base/i18n';
6 6
 import { MEDIA_TYPE } from '../../base/media';
7 7
 import { Link, Text } from '../../base/react';
8 8
 import { ColorPalette } from '../../base/styles';
9
-import { createLocalTracksA } from '../../base/tracks';
9
+import { createDesiredLocalTracks } from '../../base/tracks';
10 10
 
11 11
 import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
12 12
 import styles from './styles';
@@ -46,10 +46,7 @@ class WelcomePage extends AbstractWelcomePage {
46 46
      * @returns {void}
47 47
      */
48 48
     componentWillMount() {
49
-        const { dispatch, _localVideoTrack } = this.props;
50
-
51
-        (typeof _localVideoTrack === 'undefined')
52
-            && dispatch(createLocalTracksA({ devices: [ MEDIA_TYPE.VIDEO ] }));
49
+        this.props.dispatch(createDesiredLocalTracks(MEDIA_TYPE.VIDEO));
53 50
     }
54 51
 
55 52
     /**

Loading…
Cancel
Save