瀏覽代碼

[RN] Weaken the coupling between WelcomePage and AbstractWelcomePage

master
Lyubo Marinov 8 年之前
父節點
當前提交
b304ad5808
共有 2 個文件被更改,包括 13 次插入14 次删除
  1. 11
    9
      react/features/base/tracks/actions.js
  2. 2
    5
      react/features/welcome/components/WelcomePage.native.js

+ 11
- 9
react/features/base/tracks/actions.js 查看文件

17
 
17
 
18
 /**
18
 /**
19
  * Requests the creating of the desired media type tracks. Desire is expressed
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
  * @returns {Function}
25
  * @returns {Function}
25
  */
26
  */
26
-export function createDesiredLocalTracks() {
27
+export function createDesiredLocalTracks(...desiredTypes) {
27
     return (dispatch, getState) => {
28
     return (dispatch, getState) => {
28
         const state = getState();
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
         const availableTypes
38
         const availableTypes
37
             = state['features/base/tracks']
39
             = state['features/base/tracks']

+ 2
- 5
react/features/welcome/components/WelcomePage.native.js 查看文件

6
 import { MEDIA_TYPE } from '../../base/media';
6
 import { MEDIA_TYPE } from '../../base/media';
7
 import { Link, Text } from '../../base/react';
7
 import { Link, Text } from '../../base/react';
8
 import { ColorPalette } from '../../base/styles';
8
 import { ColorPalette } from '../../base/styles';
9
-import { createLocalTracksA } from '../../base/tracks';
9
+import { createDesiredLocalTracks } from '../../base/tracks';
10
 
10
 
11
 import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
11
 import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
12
 import styles from './styles';
12
 import styles from './styles';
46
      * @returns {void}
46
      * @returns {void}
47
      */
47
      */
48
     componentWillMount() {
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…
取消
儲存