[RN] Weaken the coupling between WelcomePage and AbstractWelcomePage

This commit is contained in:
Lyubo Marinov 2017-09-05 16:27:12 -05:00
parent 86e4876df2
commit b304ad5808
2 changed files with 13 additions and 14 deletions

View File

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

View File

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