Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

[RN] Weaken the coupling between WelcomePage and AbstractWelcomePage

Lyubo Marinovb304ad58082d
diff --git a/react/features/base/tracks/actions.js b/react/features/base/tracks/actions.js
index cc2c045568..eec5d6d154 100644
--- a/react/features/base/tracks/actions.js
+++ b/react/features/base/tracks/actions.js
@@ -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']
diff --git a/react/features/welcome/components/WelcomePage.native.js b/react/features/welcome/components/WelcomePage.native.js
index 1d37a7f999..3eb518d8f8 100644
--- a/react/features/welcome/components/WelcomePage.native.js
+++ b/react/features/welcome/components/WelcomePage.native.js
@@ -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));
}
/**