[RN] Weaken the coupling between WelcomePage and AbstractWelcomePage
This commit is contained in:
parent
86e4876df2
commit
b304ad5808
|
@ -17,21 +17,23 @@ import { createLocalTracksF } from './functions';
|
|||
|
||||
/**
|
||||
* Requests the creating of the desired media type tracks. Desire is expressed
|
||||
* by base/media. This function will dispatch a {@code createLocalTracksA}
|
||||
* action for the "missing" types, that is, the ones which base/media would
|
||||
* like to have (unmuted tracks) but are not present yet.
|
||||
* by base/media unless the function caller specifies desired media types
|
||||
* explicitly and thus override base/media. Dispatches a
|
||||
* {@code createLocalTracksA} action for the desired media types for which there
|
||||
* are no existing tracks yet.
|
||||
*
|
||||
* @returns {Function}
|
||||
*/
|
||||
export function createDesiredLocalTracks() {
|
||||
export function createDesiredLocalTracks(...desiredTypes) {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const desiredTypes = [];
|
||||
|
||||
state['features/base/media'].audio.muted
|
||||
|| desiredTypes.push(MEDIA_TYPE.AUDIO);
|
||||
Boolean(state['features/base/media'].video.muted)
|
||||
|| desiredTypes.push(MEDIA_TYPE.VIDEO);
|
||||
if (desiredTypes.length === 0) {
|
||||
const { audio, video } = state['features/base/media'];
|
||||
|
||||
audio.muted || desiredTypes.push(MEDIA_TYPE.AUDIO);
|
||||
Boolean(video.muted) || desiredTypes.push(MEDIA_TYPE.VIDEO);
|
||||
}
|
||||
|
||||
const availableTypes
|
||||
= state['features/base/tracks']
|
||||
|
|
|
@ -6,7 +6,7 @@ import { translate } from '../../base/i18n';
|
|||
import { MEDIA_TYPE } from '../../base/media';
|
||||
import { Link, Text } from '../../base/react';
|
||||
import { ColorPalette } from '../../base/styles';
|
||||
import { createLocalTracksA } from '../../base/tracks';
|
||||
import { createDesiredLocalTracks } from '../../base/tracks';
|
||||
|
||||
import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
|
||||
import styles from './styles';
|
||||
|
@ -46,10 +46,7 @@ class WelcomePage extends AbstractWelcomePage {
|
|||
* @returns {void}
|
||||
*/
|
||||
componentWillMount() {
|
||||
const { dispatch, _localVideoTrack } = this.props;
|
||||
|
||||
(typeof _localVideoTrack === 'undefined')
|
||||
&& dispatch(createLocalTracksA({ devices: [ MEDIA_TYPE.VIDEO ] }));
|
||||
this.props.dispatch(createDesiredLocalTracks(MEDIA_TYPE.VIDEO));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue