Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

[RN] Catch Promise rejection

Lyubomir Marinov99c2b60a1d8f
diff --git a/react/features/app/actions.js b/react/features/app/actions.js
index c0f030b9ce..ef0566ddd1 100644
--- a/react/features/app/actions.js
+++ b/react/features/app/actions.js
@@ -50,18 +50,41 @@ export function appNavigate(urlOrRoom) {
// race conditions when we will start to load config multiple times.
dispatch(setDomain(domain));
- // If domain has changed, that means we need to load new config
- // for that new domain and set it, and only after that we can
- // navigate to different route.
+ // If domain has changed, we need to load the config of the new
+ // domain and set it, and only after that we can navigate to
+ // different route.
loadConfig(`https://${domain}`)
- .then(config => {
- // 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());
- });
+ .then(
+ config => configLoaded(/* err */ undefined, config),
+ err => configLoaded(err, /* config */ undefined));
+ }
+
+ /**
+ * 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());
}
};
}