fix(rn, web) await initialisation before dispatching appWillMount

This commit is contained in:
tmoldovan8x8
2022-01-07 15:18:24 +02:00
committed by GitHub
parent 8de024a699
commit 307e253276
5 changed files with 114 additions and 95 deletions

View File

@@ -38,14 +38,12 @@ export class AbstractApp extends BaseApp<Props, *> {
*
* @inheritdoc
*/
componentDidMount() {
super.componentDidMount();
async componentDidMount() {
await super.componentDidMount();
this._init.then(() => {
// If a URL was explicitly specified to this React Component, then
// open it; otherwise, use a default.
this._openURL(toURLString(this.props.url) || this._getDefaultURL());
});
// If a URL was explicitly specified to this React Component, then
// open it; otherwise, use a default.
this._openURL(toURLString(this.props.url) || this._getDefaultURL());
}
/**
@@ -53,23 +51,23 @@ export class AbstractApp extends BaseApp<Props, *> {
*
* @inheritdoc
*/
componentDidUpdate(prevProps: Props) {
async componentDidUpdate(prevProps: Props) {
const previousUrl = toURLString(prevProps.url);
const currentUrl = toURLString(this.props.url);
const previousTimestamp = prevProps.timestamp;
const currentTimestamp = this.props.timestamp;
this._init.then(() => {
// Deal with URL changes.
await this._init;
if (previousUrl !== currentUrl
// Deal with URL changes.
// XXX Refer to the implementation of loadURLObject: in
// ios/sdk/src/JitsiMeetView.m for further information.
|| previousTimestamp !== currentTimestamp) {
this._openURL(currentUrl || this._getDefaultURL());
}
});
if (previousUrl !== currentUrl
// XXX Refer to the implementation of loadURLObject: in
// ios/sdk/src/JitsiMeetView.m for further information.
|| previousTimestamp !== currentTimestamp) {
this._openURL(currentUrl || this._getDefaultURL());
}
}
/**

View File

@@ -81,40 +81,45 @@ export class App extends AbstractApp {
*
* @returns {void}
*/
componentDidMount() {
super.componentDidMount();
async componentDidMount() {
await super.componentDidMount();
SplashScreen.hide();
}
this._init.then(() => {
const { dispatch, getState } = this.state.store;
/**
* Initializes feature flags and updates settings.
*
* @returns {void}
*/
_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));
// We set these early enough so then we avoid any unnecessary re-renders.
dispatch(updateFlags(this.props.flags));
// Check if serverURL is configured externally and not allowed to change.
const serverURLChangeEnabled = getFeatureFlag(getState(), SERVER_URL_CHANGE_ENABLED, true);
// Check if serverURL is configured externally and not allowed to change.
const serverURLChangeEnabled = getFeatureFlag(getState(), SERVER_URL_CHANGE_ENABLED, true);
if (!serverURLChangeEnabled) {
// As serverURL is provided externally, so we push it to settings.
if (typeof this.props.url !== 'undefined') {
const { serverURL } = this.props.url;
if (!serverURLChangeEnabled) {
// As serverURL is provided externally, so we push it to settings.
if (typeof this.props.url !== 'undefined') {
const { serverURL } = this.props.url;
if (typeof serverURL !== 'undefined') {
dispatch(updateSettings({ serverURL }));
}
if (typeof serverURL !== 'undefined') {
dispatch(updateSettings({ serverURL }));
}
}
}
dispatch(updateSettings(this.props.userInfo || {}));
dispatch(updateSettings(this.props.userInfo || {}));
// Update settings with feature-flag.
const callIntegrationEnabled = this.props.flags[CALL_INTEGRATION_ENABLED];
// Update settings with feature-flag.
const callIntegrationEnabled = this.props.flags[CALL_INTEGRATION_ENABLED];
if (typeof callIntegrationEnabled !== 'undefined') {
dispatch(updateSettings({ disableCallIntegration: !callIntegrationEnabled }));
}
});
if (typeof callIntegrationEnabled !== 'undefined') {
dispatch(updateSettings({ disableCallIntegration: !callIntegrationEnabled }));
}
}
/**