[RN] Catch Promise rejection
This commit is contained in:
parent
de5cd53f85
commit
99c2b60a1d
|
@ -50,18 +50,41 @@ export function appNavigate(urlOrRoom) {
|
||||||
// race conditions when we will start to load config multiple times.
|
// race conditions when we will start to load config multiple times.
|
||||||
dispatch(setDomain(domain));
|
dispatch(setDomain(domain));
|
||||||
|
|
||||||
// If domain has changed, that means we need to load new config
|
// If domain has changed, we need to load the config of the new
|
||||||
// for that new domain and set it, and only after that we can
|
// domain and set it, and only after that we can navigate to
|
||||||
// navigate to different route.
|
// different route.
|
||||||
loadConfig(`https://${domain}`)
|
loadConfig(`https://${domain}`)
|
||||||
.then(config => {
|
.then(
|
||||||
// We set room name only here to prevent race conditions on
|
config => configLoaded(/* err */ undefined, config),
|
||||||
// app start to not make app re-render conference page for
|
err => configLoaded(err, /* config */ undefined));
|
||||||
// two times.
|
}
|
||||||
dispatch(setRoom(room));
|
|
||||||
dispatch(setConfig(config));
|
/**
|
||||||
_navigate(getState());
|
* Notifies that an attempt to load the config(uration) of domain has
|
||||||
});
|
* completed.
|
||||||
|
*
|
||||||
|
* @param {string|undefined} err - If the loading has failed, the error
|
||||||
|
* detailing the cause of the failure.
|
||||||
|
* @param {Object|undefined} config - If the loading has succeeded, the
|
||||||
|
* loaded config(uration).
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function configLoaded(err, config) {
|
||||||
|
if (err) {
|
||||||
|
// XXX The failure could be, for example, because of a
|
||||||
|
// certificate-related error. In which case the connection will
|
||||||
|
// fail later in Strophe anyway even if we use the default
|
||||||
|
// config here.
|
||||||
|
|
||||||
|
// The function loadConfig will log the err.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We set room name only here to prevent race conditions on app
|
||||||
|
// start to not make app re-render conference page for two times.
|
||||||
|
dispatch(setRoom(room));
|
||||||
|
dispatch(setConfig(config));
|
||||||
|
_navigate(getState());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue