[RN] Don't open the camera on startup when there is no welcome page

This commit is contained in:
Lyubo Marinov 2017-07-18 23:42:08 -05:00
parent 8225600b61
commit d87b8823e9
1 changed files with 25 additions and 16 deletions

View File

@ -76,22 +76,31 @@ function _navigate({ dispatch, getState }) {
const { app, getRouteToRender } = state['features/app']; const { app, getRouteToRender } = state['features/app'];
const routeToRender = getRouteToRender && getRouteToRender(state); const routeToRender = getRouteToRender && getRouteToRender(state);
// Create/destroy the local tracks as needed: create them the first time we // FIXME The following is logic specific to the user experience of the
// are going to render an actual route (be that the WelcomePage or the // mobile/React Native app. Firstly, I don't like that it's here at all.
// Conference). // Secondly, I copied the mobile/React Native detection from
// // react/features/base/config/reducer.js because I couldn't iron out an
// When the WelcomePage is disabled, the app will transition to the // abstraction. Because of the first point, I'm leaving the second point
// null/undefined route. Detect these transitions and create/destroy the // unresolved to attract attention to the fact that the following needs more
// local tracks so the camera doesn't stay open if the app is not rendering // thinking.
// any component. if (navigator.userAgent.match(/react[ \s-]*native/i)) {
if (typeof routeToRender === 'undefined' || routeToRender === null) { // Create/destroy the local tracks as needed: create them the first time
// Destroy the local tracks if there is no route to render and there is // we are going to render an actual route (be that the WelcomePage or
// no welcome page. // the Conference).
app.props.welcomePageEnabled || dispatch(destroyLocalTracks()); //
} else { // When the WelcomePage is disabled, the app will transition to the
// Create the local tracks if they haven't been created yet. // null/undefined route. Detect these transitions and create/destroy the
state['features/base/tracks'].some(t => t.local) // local tracks so the camera doesn't stay open if the app is not
|| dispatch(createInitialLocalTracks()); // rendering any component.
if (typeof routeToRender === 'undefined' || routeToRender === null) {
// Destroy the local tracks if there is no route to render and there
// is no WelcomePage.
app.props.welcomePageEnabled || dispatch(destroyLocalTracks());
} else {
// Create the local tracks if they haven't been created yet.
state['features/base/tracks'].some(t => t.local)
|| dispatch(createInitialLocalTracks());
}
} }
app._navigate(routeToRender); app._navigate(routeToRender);