diff --git a/react/features/app/components/App.native.js b/react/features/app/components/App.native.js index e15a835a4..b374d38b5 100644 --- a/react/features/app/components/App.native.js +++ b/react/features/app/components/App.native.js @@ -28,11 +28,6 @@ declare var __DEV__; */ type Props = AbstractAppProps & { - /** - * An object of colors that override the default colors of the app/sdk. - */ - colorScheme: ?Object, - /** * Identifier for this app on the native side. */ @@ -100,13 +95,31 @@ export class App extends AbstractApp { */ async _extraInit() { const { dispatch, getState } = this.state.store; + + // We set these early enough so then we avoid any unnecessary re-renders. + dispatch(updateFlags(this.props.flags)); + const route = await _getRouteToRender(); // We need the root navigator to be set early. await this._navigate(route); - // We set these early enough so then we avoid any unnecessary re-renders. - dispatch(updateFlags(this.props.flags)); + // HACK ALERT! + // Wait until the root navigator is ready. + // We really need to break the inheritance relationship between App, + // AbstractApp and BaseApp, it's very inflexible and cumbersome right now. + const rootNavigationReady = new Promise(resolve => { + const i = setInterval(() => { + const { ready } = getState()['features/app'] || {}; + + if (ready) { + clearInterval(i); + resolve(); + } + }, 50); + }); + + await rootNavigationReady; // Check if serverURL is configured externally and not allowed to change. const serverURLChangeEnabled = getFeatureFlag(getState(), SERVER_URL_CHANGE_ENABLED, true); diff --git a/react/features/app/reducer.native.js b/react/features/app/reducer.native.js new file mode 100644 index 000000000..79255c240 --- /dev/null +++ b/react/features/app/reducer.native.js @@ -0,0 +1,22 @@ +import { ReducerRegistry } from '../base/redux'; +import { _ROOT_NAVIGATION_READY } from '../mobile/navigation/actionTypes'; + +/** + * Listen for actions which changes the state of the app feature. + * + * @param {Object} state - The Redux state of the feature features/app. + * @param {Object} action - Action object. + * @param {string} action.type - Type of action. + * @returns {Object} + */ +ReducerRegistry.register('features/app', (state = {}, action) => { + switch (action.type) { + case _ROOT_NAVIGATION_READY: + return { + ...state, + ready: action.ready + }; + default: + return state; + } +}); diff --git a/react/features/app/reducers.native.js b/react/features/app/reducers.native.js index 0c1939450..82ecc1d8e 100644 --- a/react/features/app/reducers.native.js +++ b/react/features/app/reducers.native.js @@ -8,4 +8,6 @@ import '../mobile/full-screen/reducer'; import '../mobile/watchos/reducer'; import '../shared-video/reducer'; +import './reducer.native'; + import './reducers.any'; diff --git a/react/features/mobile/navigation/actionTypes.js b/react/features/mobile/navigation/actionTypes.js new file mode 100644 index 000000000..aa15fe033 --- /dev/null +++ b/react/features/mobile/navigation/actionTypes.js @@ -0,0 +1 @@ +export const _ROOT_NAVIGATION_READY = '_ROOT_NAVIGATION_READY'; diff --git a/react/features/mobile/navigation/components/RootNavigationContainer.js b/react/features/mobile/navigation/components/RootNavigationContainer.js index a49142076..362a25fcc 100644 --- a/react/features/mobile/navigation/components/RootNavigationContainer.js +++ b/react/features/mobile/navigation/components/RootNavigationContainer.js @@ -1,9 +1,10 @@ import { NavigationContainer } from '@react-navigation/native'; import { createStackNavigator } from '@react-navigation/stack'; -import React from 'react'; +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 { @@ -23,6 +24,11 @@ const RootStack = createStackNavigator(); type Props = { + /** + * Redux dispatch function. + */ + dispatch: Function, + /** * Is welcome page available? */ @@ -30,13 +36,20 @@ type Props = { } -const RootNavigationContainer = ({ isWelcomePageAvailable }: Props) => { +const RootNavigationContainer = ({ dispatch, isWelcomePageAvailable }: Props) => { const initialRouteName = isWelcomePageAvailable ? screen.root : screen.connecting; + const onReady = useCallback(() => { + dispatch({ + type: _ROOT_NAVIGATION_READY, + ready: true + }); + }, [ dispatch ]); return (