Browse Source

[RN] Handle config loading errors

They will be stored in redux and the PageReloadOverlay will be displayed.

Note that this commit also introduces a subtle (and yet important!) change:
the location URL is now always set, regardless of the configuration loading or
not. This is needed in order for the retry logic to pick it up.
master
Saúl Ibarra Corretgé 8 years ago
parent
commit
c05c8e0f1e

+ 10
- 11
react/features/app/actions.js View File

1
 /* @flow */
1
 /* @flow */
2
 
2
 
3
 import { setRoom } from '../base/conference';
3
 import { setRoom } from '../base/conference';
4
-import { loadConfigError, setConfig } from '../base/config';
4
+import { configWillLoad, loadConfigError, setConfig } from '../base/config';
5
 import { setLocationURL } from '../base/connection';
5
 import { setLocationURL } from '../base/connection';
6
 import { loadConfig } from '../base/lib-jitsi-meet';
6
 import { loadConfig } from '../base/lib-jitsi-meet';
7
 import { parseURIString } from '../base/util';
7
 import { parseURIString } from '../base/util';
44
 ): Promise<void> {
44
 ): Promise<void> {
45
     const { room } = newLocation;
45
     const { room } = newLocation;
46
 
46
 
47
+    dispatch(configWillLoad(newLocation));
48
+
47
     return (
49
     return (
48
         _loadConfig(newLocation)
50
         _loadConfig(newLocation)
49
             .then(
51
             .then(
67
         // config may or may not be required by the time the notification
69
         // config may or may not be required by the time the notification
68
         // arrives.
70
         // arrives.
69
 
71
 
72
+        const promise
73
+            = dispatch(setLocationURL(new URL(newLocation.toString())));
74
+
70
         if (error) {
75
         if (error) {
71
             // XXX The failure could be, for example, because of a
76
             // XXX The failure could be, for example, because of a
72
             // certificate-related error. In which case the connection will
77
             // certificate-related error. In which case the connection will
73
             // fail later in Strophe anyway.
78
             // fail later in Strophe anyway.
74
-            dispatch(loadConfigError(error, newLocation));
75
-
76
-            // Cannot go to a room if its configuration failed to load.
77
-            if (room) {
78
-                dispatch(appNavigate(undefined));
79
-
79
+            return promise.then(() => {
80
+                dispatch(loadConfigError(error, newLocation));
80
                 throw error;
81
                 throw error;
81
-            }
82
+            });
82
         }
83
         }
83
 
84
 
84
-        return (
85
-            dispatch(setLocationURL(new URL(newLocation.toString())))
86
-                .then(() => dispatch(setConfig(config))));
85
+        return promise.then(() => dispatch(setConfig(config)));
87
     }
86
     }
88
 }
87
 }
89
 
88
 

+ 11
- 0
react/features/base/config/actionTypes.js View File

1
+/**
2
+ * The redux action which signals that a configuration will be loaded for a
3
+ * specific locationURL.
4
+ *
5
+ * {
6
+ *     type: CONFIG_WILL_LOAD,
7
+ *     locationURL: string | URL
8
+ * }
9
+ */
10
+export const CONFIG_WILL_LOAD = Symbol('CONFIG_WILL_LOAD');
11
+
1
 /**
12
 /**
2
  * The redux action which signals that a configuration could not be loaded due
13
  * The redux action which signals that a configuration could not be loaded due
3
  * to a specific error.
14
  * to a specific error.

+ 22
- 1
react/features/base/config/actions.js View File

1
 /* @flow */
1
 /* @flow */
2
 
2
 
3
-import { LOAD_CONFIG_ERROR, SET_CONFIG } from './actionTypes';
3
+import {
4
+    CONFIG_WILL_LOAD,
5
+    LOAD_CONFIG_ERROR,
6
+    SET_CONFIG
7
+} from './actionTypes';
8
+
9
+/**
10
+ * Signals that the configuration for a specific locationURL will be loaded now.
11
+ *
12
+ * @param {string|URL} locationURL - The URL of the location which necessitated
13
+ * the loading of a configuration.
14
+ * @returns {{
15
+ *     type: CONFIG_WILL_LOAD,
16
+ *     locationURL
17
+ * }}
18
+ */
19
+export function configWillLoad(locationURL: string | URL) {
20
+    return {
21
+        type: CONFIG_WILL_LOAD,
22
+        locationURL
23
+    };
24
+}
4
 
25
 
5
 /**
26
 /**
6
  * Signals that a configuration could not be loaded due to a specific error.
27
  * Signals that a configuration could not be loaded due to a specific error.

+ 19
- 4
react/features/base/config/reducer.js View File

4
 
4
 
5
 import { equals, ReducerRegistry, set } from '../redux';
5
 import { equals, ReducerRegistry, set } from '../redux';
6
 
6
 
7
-import { SET_CONFIG } from './actionTypes';
7
+import {
8
+    CONFIG_WILL_LOAD,
9
+    LOAD_CONFIG_ERROR,
10
+    SET_CONFIG
11
+} from './actionTypes';
8
 
12
 
9
 /**
13
 /**
10
  * The initial state of the feature base/config when executing in a
14
  * The initial state of the feature base/config when executing in a
47
     'features/base/config',
51
     'features/base/config',
48
     (state = _getInitialState(), action) => {
52
     (state = _getInitialState(), action) => {
49
         switch (action.type) {
53
         switch (action.type) {
54
+        case CONFIG_WILL_LOAD:
55
+            return {
56
+                error: undefined
57
+            };
58
+
59
+        case LOAD_CONFIG_ERROR:
60
+            return {
61
+                error: action.error
62
+            };
63
+
50
         case SET_CONFIG:
64
         case SET_CONFIG:
51
             return _setConfig(state, action);
65
             return _setConfig(state, action);
52
 
66
 
81
  * @returns {Object} The new state of the feature base/lib-jitsi-meet after the
95
  * @returns {Object} The new state of the feature base/lib-jitsi-meet after the
82
  * reduction of the specified action.
96
  * reduction of the specified action.
83
  */
97
  */
84
-function _setConfig(state, action) {
85
-    let { config } = action;
86
-
98
+function _setConfig(state, { config }) {
87
     // The mobile app bundles jitsi-meet and lib-jitsi-meet at build time and
99
     // The mobile app bundles jitsi-meet and lib-jitsi-meet at build time and
88
     // does not download them at runtime from the deployment on which it will
100
     // does not download them at runtime from the deployment on which it will
89
     // join a conference. The downloading is planned for implementation in the
101
     // join a conference. The downloading is planned for implementation in the
90
     // future (later rather than sooner) but is not implemented yet at the time
102
     // future (later rather than sooner) but is not implemented yet at the time
91
     // of this writing and, consequently, we must provide legacy support in the
103
     // of this writing and, consequently, we must provide legacy support in the
92
     // meantime.
104
     // meantime.
105
+
106
+    // eslint-disable-next-line no-param-reassign
93
     config = _translateLegacyConfig(config);
107
     config = _translateLegacyConfig(config);
94
 
108
 
95
     const newState = _.merge(
109
     const newState = _.merge(
96
         {},
110
         {},
97
         config,
111
         config,
112
+        { error: undefined },
98
 
113
 
99
         // The config of _getInitialState() is meant to override the config
114
         // The config of _getInitialState() is meant to override the config
100
         // downloaded from the Jitsi Meet deployment because the former contains
115
         // downloaded from the Jitsi Meet deployment because the former contains

+ 5
- 2
react/features/overlay/components/AbstractPageReloadOverlay.js View File

66
      */
66
      */
67
     static needsRender(state) {
67
     static needsRender(state) {
68
         const conferenceError = state['features/base/conference'].error;
68
         const conferenceError = state['features/base/conference'].error;
69
+        const configError = state['features/base/config'].error;
69
         const connectionError = state['features/base/connection'].error;
70
         const connectionError = state['features/base/connection'].error;
70
 
71
 
71
         return (
72
         return (
72
             (connectionError && isFatalJitsiConnectionError(connectionError))
73
             (connectionError && isFatalJitsiConnectionError(connectionError))
73
                 || (conferenceError
74
                 || (conferenceError
74
                     && isFatalJitsiConferenceError(conferenceError))
75
                     && isFatalJitsiConferenceError(conferenceError))
76
+                || configError
75
         );
77
         );
76
     }
78
     }
77
 
79
 
253
  */
255
  */
254
 export function abstractMapStateToProps(state: Object) {
256
 export function abstractMapStateToProps(state: Object) {
255
     const conferenceError = state['features/base/conference'].error;
257
     const conferenceError = state['features/base/conference'].error;
258
+    const configError = state['features/base/config'].error;
256
     const connectionError = state['features/base/connection'].error;
259
     const connectionError = state['features/base/connection'].error;
257
 
260
 
258
     return {
261
     return {
259
-        isNetworkFailure: Boolean(connectionError),
260
-        reason: (connectionError || conferenceError).message
262
+        isNetworkFailure: Boolean(configError || connectionError),
263
+        reason: (configError || connectionError || conferenceError).message
261
     };
264
     };
262
 }
265
 }

Loading…
Cancel
Save