Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(rn,navigation) wait until the root navigator is initialized
Saúl Ibarra Corretgée6ce5fd75f3c
diff --git a/react/features/app/components/App.native.js b/react/features/app/components/App.native.jsindex e15a835a46..b374d38b53 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.jsnew file mode 100644index 0000000000..79255c2409--- /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.jsindex 0c19394503..82ecc1d8e0 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.jsnew file mode 100644index 0000000000..aa15fe033d--- /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.jsindex a49142076d..362a25fcce 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 (<NavigationContainerindependent = { true }+ onReady = { onReady }ref = { rootNavigationRef }theme = { navigationContainerTheme }><RootStack.Navigator@@ -86,4 +99,3 @@ function mapStateToProps(state: Object) {}export default connect(mapStateToProps)(RootNavigationContainer);-