mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-15 02:17:48 +00:00
There is a race condition in the root navigatior's initialization.
It's possible that it's initialized a touch too late and SDK users who
try to navigate to a conference end up stuck in the connecting screen
because the navigator is null.
This PR waits for it to be initilized by very unorthodox means, it's a
horrible hack which we need to undo, but for that we need to break
appart the inheritance relationship between App.{web,native},
AbstractApp and BaseApp because it's very inflexible.
The flags are now initialized very early so the naviggator sees if the
welcome page is enabled or not.
102 lines
3.3 KiB
JavaScript
102 lines
3.3 KiB
JavaScript
import { NavigationContainer } from '@react-navigation/native';
|
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { connect } from '../../../base/redux';
|
|
import { DialInSummary } from '../../../invite';
|
|
import { _ROOT_NAVIGATION_READY } from '../actionTypes';
|
|
import { rootNavigationRef } from '../rootNavigationContainerRef';
|
|
import { screen } from '../routes';
|
|
import {
|
|
dialInSummaryScreenOptions,
|
|
drawerNavigatorScreenOptions,
|
|
navigationContainerTheme
|
|
} from '../screenOptions';
|
|
|
|
import ConnectingPage from './ConnectingPage';
|
|
import ConferenceNavigationContainer
|
|
from './conference/components/ConferenceNavigationContainer';
|
|
import WelcomePageNavigationContainer from './welcome/components/WelcomePageNavigationContainer';
|
|
import { isWelcomePageAppEnabled } from './welcome/functions';
|
|
|
|
const RootStack = createStackNavigator();
|
|
|
|
|
|
type Props = {
|
|
|
|
/**
|
|
* Redux dispatch function.
|
|
*/
|
|
dispatch: Function,
|
|
|
|
/**
|
|
* Is welcome page available?
|
|
*/
|
|
isWelcomePageAvailable: boolean
|
|
}
|
|
|
|
|
|
const RootNavigationContainer = ({ dispatch, isWelcomePageAvailable }: Props) => {
|
|
const initialRouteName = isWelcomePageAvailable
|
|
? screen.root : screen.connecting;
|
|
const onReady = useCallback(() => {
|
|
dispatch({
|
|
type: _ROOT_NAVIGATION_READY,
|
|
ready: true
|
|
});
|
|
}, [ dispatch ]);
|
|
|
|
return (
|
|
<NavigationContainer
|
|
independent = { true }
|
|
onReady = { onReady }
|
|
ref = { rootNavigationRef }
|
|
theme = { navigationContainerTheme }>
|
|
<RootStack.Navigator
|
|
initialRouteName = { initialRouteName }>
|
|
{
|
|
isWelcomePageAvailable
|
|
&& <>
|
|
<RootStack.Screen
|
|
component = { WelcomePageNavigationContainer }
|
|
name = { screen.root }
|
|
options = { drawerNavigatorScreenOptions } />
|
|
<RootStack.Screen
|
|
component = { DialInSummary }
|
|
name = { screen.dialInSummary }
|
|
options = { dialInSummaryScreenOptions } />
|
|
</>
|
|
}
|
|
<RootStack.Screen
|
|
component = { ConnectingPage }
|
|
name = { screen.connecting }
|
|
options = {{
|
|
gestureEnabled: false,
|
|
headerShown: false
|
|
}} />
|
|
<RootStack.Screen
|
|
component = { ConferenceNavigationContainer }
|
|
name = { screen.conference.root }
|
|
options = {{
|
|
gestureEnabled: false,
|
|
headerShown: false
|
|
}} />
|
|
</RootStack.Navigator>
|
|
</NavigationContainer>
|
|
);
|
|
};
|
|
|
|
/**
|
|
* Maps part of the Redux store to the props of this component.
|
|
*
|
|
* @param {Object} state - The Redux state.
|
|
* @returns {Props}
|
|
*/
|
|
function mapStateToProps(state: Object) {
|
|
return {
|
|
isWelcomePageAvailable: isWelcomePageAppEnabled(state)
|
|
};
|
|
}
|
|
|
|
export default connect(mapStateToProps)(RootNavigationContainer);
|