Переглянути джерело

[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 роки тому
джерело
коміт
c05c8e0f1e

+ 10
- 11
react/features/app/actions.js Переглянути файл

@@ -1,7 +1,7 @@
1 1
 /* @flow */
2 2
 
3 3
 import { setRoom } from '../base/conference';
4
-import { loadConfigError, setConfig } from '../base/config';
4
+import { configWillLoad, loadConfigError, setConfig } from '../base/config';
5 5
 import { setLocationURL } from '../base/connection';
6 6
 import { loadConfig } from '../base/lib-jitsi-meet';
7 7
 import { parseURIString } from '../base/util';
@@ -44,6 +44,8 @@ function _appNavigateToMandatoryLocation(
44 44
 ): Promise<void> {
45 45
     const { room } = newLocation;
46 46
 
47
+    dispatch(configWillLoad(newLocation));
48
+
47 49
     return (
48 50
         _loadConfig(newLocation)
49 51
             .then(
@@ -67,23 +69,20 @@ function _appNavigateToMandatoryLocation(
67 69
         // config may or may not be required by the time the notification
68 70
         // arrives.
69 71
 
72
+        const promise
73
+            = dispatch(setLocationURL(new URL(newLocation.toString())));
74
+
70 75
         if (error) {
71 76
             // XXX The failure could be, for example, because of a
72 77
             // certificate-related error. In which case the connection will
73 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 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 Переглянути файл

@@ -1,3 +1,14 @@
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 13
  * The redux action which signals that a configuration could not be loaded due
3 14
  * to a specific error.

+ 22
- 1
react/features/base/config/actions.js Переглянути файл

@@ -1,6 +1,27 @@
1 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 27
  * Signals that a configuration could not be loaded due to a specific error.

+ 19
- 4
react/features/base/config/reducer.js Переглянути файл

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

+ 5
- 2
react/features/overlay/components/AbstractPageReloadOverlay.js Переглянути файл

@@ -66,12 +66,14 @@ export default class AbstractPageReloadOverlay extends Component<*, *> {
66 66
      */
67 67
     static needsRender(state) {
68 68
         const conferenceError = state['features/base/conference'].error;
69
+        const configError = state['features/base/config'].error;
69 70
         const connectionError = state['features/base/connection'].error;
70 71
 
71 72
         return (
72 73
             (connectionError && isFatalJitsiConnectionError(connectionError))
73 74
                 || (conferenceError
74 75
                     && isFatalJitsiConferenceError(conferenceError))
76
+                || configError
75 77
         );
76 78
     }
77 79
 
@@ -253,10 +255,11 @@ export default class AbstractPageReloadOverlay extends Component<*, *> {
253 255
  */
254 256
 export function abstractMapStateToProps(state: Object) {
255 257
     const conferenceError = state['features/base/conference'].error;
258
+    const configError = state['features/base/config'].error;
256 259
     const connectionError = state['features/base/connection'].error;
257 260
 
258 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
 }

Завантаження…
Відмінити
Зберегти