Browse Source

[RN] Report loadConfigError with locationURL to the SDK consumers

master
Lyubo Marinov 7 years ago
parent
commit
fce0e4c22c

+ 4
- 2
android/README.md View File

@@ -244,6 +244,8 @@ The `data` `Map` contains a "url" key with the conference URL.
244 244
 
245 245
 #### onLoadConfigError
246 246
 
247
-Called when loading the main configuration fails.
247
+Called when loading the main configuration file from the Jitsi Meet deployment
248
+fails.
248 249
 
249
-The `data` `Map` contains an "error" key with the error.
250
+The `data` `Map` contains an "error" key with the error and a "url" key with the
251
+conference URL which necessitated the loading of the configuration file.

+ 5
- 2
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetViewListener.java View File

@@ -60,9 +60,12 @@ public interface JitsiMeetViewListener {
60 60
     void onConferenceWillLeave(Map<String, Object> data);
61 61
 
62 62
     /**
63
-     * Called when loading the main configuration fails.
63
+     * Called when loading the main configuration file from the Jitsi Meet
64
+     * deployment fails.
64 65
      *
65
-     * @param data - Map with an "error" key with the error.
66
+     * @param data - Map with an "error" key with the error and a "url" key with
67
+     * the conference URL which necessitated the loading of the configuration
68
+     * file.
66 69
      */
67 70
     void onLoadConfigError(Map<String, Object> data);
68 71
 }

+ 5
- 2
ios/README.md View File

@@ -153,6 +153,9 @@ The `data` dictionary contains a "url" key with the conference URL.
153 153
 
154 154
 #### loadConfigError
155 155
 
156
-Called when loading the main configuration fails.
156
+Called when loading the main configuration file from the Jitsi Meet deployment
157
+fails.
157 158
 
158
-The `data` dictionary contains an "error" key with the error.
159
+The `data` dictionary contains an "error" key with the error and a "url" key
160
+with the conference URL which necessitated the loading of the configuration
161
+file.

+ 5
- 2
ios/sdk/src/JitsiMeetViewDelegate.h View File

@@ -60,9 +60,12 @@
60 60
 - (void)conferenceWillLeave:(NSDictionary *)data;
61 61
 
62 62
 /**
63
- * Called when loading the main configuration file fails.
63
+ * Called when loading the main configuration file from the Jitsi Meet
64
+ * deployment file.
64 65
  *
65
- * The {@code data} dictionary contains an {@code error} key with the error.
66
+ * The {@code data} dictionary contains an {@code error} key with the error and
67
+ * a {@code url} key with the conference URL which necessitated the loading of
68
+ * the configuration file.
66 69
  */
67 70
 - (void)loadConfigError:(NSDictionary *)data;
68 71
 

+ 18
- 15
react/features/app/actions.js View File

@@ -1,6 +1,6 @@
1 1
 import { setRoom } from '../base/conference';
2
-import { setLocationURL } from '../base/connection';
3 2
 import { loadConfigError, setConfig } from '../base/config';
3
+import { setLocationURL } from '../base/connection';
4 4
 import { loadConfig } from '../base/lib-jitsi-meet';
5 5
 import { parseURIString } from '../base/util';
6 6
 
@@ -39,11 +39,14 @@ export function appNavigate(uri: ?string) {
39 39
 function _appNavigateToMandatoryLocation(
40 40
         dispatch: Dispatch<*>, getState: Function,
41 41
         newLocation: Object) {
42
-    _loadConfig(newLocation)
43
-        .then(
44
-            config => configLoaded(/* err */ undefined, config),
45
-            err => configLoaded(err, /* config */ undefined))
46
-        .then(() => dispatch(setRoom(newLocation.room)));
42
+    const { room } = newLocation;
43
+
44
+    return (
45
+        _loadConfig(newLocation)
46
+            .then(
47
+                config => loadConfigSettled(/* error */ undefined, config),
48
+                error => loadConfigSettled(error, /* config */ undefined))
49
+            .then(() => dispatch(setRoom(room))));
47 50
 
48 51
     /**
49 52
      * Notifies that an attempt to load a configuration has completed. Due to
@@ -56,7 +59,7 @@ function _appNavigateToMandatoryLocation(
56 59
      * loaded configuration.
57 60
      * @returns {void}
58 61
      */
59
-    function configLoaded(error, config) {
62
+    function loadConfigSettled(error, config) {
60 63
         // FIXME Due to the asynchronous nature of the loading, the specified
61 64
         // config may or may not be required by the time the notification
62 65
         // arrives.
@@ -64,15 +67,15 @@ function _appNavigateToMandatoryLocation(
64 67
         if (error) {
65 68
             // XXX The failure could be, for example, because of a
66 69
             // certificate-related error. In which case the connection will
67
-            // fail later in Strophe anyway even if we use the default
68
-            // config here.
69
-            dispatch(loadConfigError(error));
70
+            // fail later in Strophe anyway.
71
+            dispatch(loadConfigError(error, newLocation));
70 72
 
71
-            // We cannot go to the requested room if we weren't able to load
72
-            // the configuration. Go back to the entryway.
73
-            newLocation.room = undefined;
73
+            // Cannot go to a room if its configuration failed to load.
74
+            if (room) {
75
+                dispatch(appNavigate(undefined));
74 76
 
75
-            return;
77
+                throw error;
78
+            }
76 79
         }
77 80
 
78 81
         return (
@@ -117,7 +120,7 @@ function _appNavigateToOptionalLocation(
117 120
 
118 121
     location.protocol || (location.protocol = 'https:');
119 122
 
120
-    _appNavigateToMandatoryLocation(dispatch, getState, location);
123
+    return _appNavigateToMandatoryLocation(dispatch, getState, location);
121 124
 }
122 125
 
123 126
 /**

+ 4
- 3
react/features/base/config/actionTypes.js View File

@@ -1,10 +1,11 @@
1 1
 /**
2
- * The redux action which signals the configuration couldn't be loaded due to an
3
- * error.
2
+ * The redux action which signals that a configuration could not be loaded due
3
+ * to a specific error.
4 4
  *
5 5
  * {
6 6
  *     type: LOAD_CONFIG_ERROR,
7
- *     error: Error
7
+ *     error: Error,
8
+ *     locationURL: string | URL
8 9
  * }
9 10
  */
10 11
 export const LOAD_CONFIG_ERROR = Symbol('LOAD_CONFIG_ERROR');

+ 11
- 6
react/features/base/config/actions.js View File

@@ -3,18 +3,23 @@
3 3
 import { LOAD_CONFIG_ERROR, SET_CONFIG } from './actionTypes';
4 4
 
5 5
 /**
6
- * Signals an error when loading the configuration.
6
+ * Signals that a configuration could not be loaded due to a specific error.
7 7
  *
8
- * @param {Error} error - The error which caused the config to not be loaded.
8
+ * @param {Error} error - The {@code Error} which prevented the successful
9
+ * loading of a configuration.
10
+ * @param {string|URL} locationURL - The URL of the location which necessitated
11
+ * the loading of a configuration.
9 12
  * @returns {{
10
- *      type: LOAD_CONFIG_ERROR,
11
- *      error: Error
13
+ *     type: LOAD_CONFIG_ERROR,
14
+ *     error: Error,
15
+ *     locationURL
12 16
  * }}
13 17
  */
14
-export function loadConfigError(error: Error) {
18
+export function loadConfigError(error: Error, locationURL: string | URL) {
15 19
     return {
16 20
         type: LOAD_CONFIG_ERROR,
17
-        error
21
+        error,
22
+        locationURL
18 23
     };
19 24
 }
20 25
 

+ 6
- 1
react/features/base/util/uri.js View File

@@ -382,7 +382,12 @@ export function urlObjectToString(o: Object): ?string {
382 382
 
383 383
         if (domain) {
384 384
             const { host, hostname, pathname: contextRoot, port }
385
-                = parseStandardURIString(domain);
385
+                = parseStandardURIString(
386
+
387
+                    // XXX The value of domain in supposed to be host/hostname
388
+                    // and, optionally, pathname. Make sure it is not taken for
389
+                    // a pathname only.
390
+                    _fixURIStringScheme(`org.jitsi.meet://${domain}`));
386 391
 
387 392
             // authority
388 393
             if (host) {

+ 6
- 10
react/features/mobile/external-api/middleware.js View File

@@ -39,21 +39,17 @@ MiddlewareRegistry.register(store => next => action => {
39 39
             data.url = toURLString(conference[JITSI_CONFERENCE_URL_KEY]);
40 40
         }
41 41
 
42
-        // The (externa API) event's name is the string representation of the
43
-        // (redux) action's type.
44
-        const name = _getSymbolDescription(type);
45
-
46
-        _sendEvent(store, name, data);
42
+        _sendEvent(store, _getSymbolDescription(type), data);
47 43
         break;
48 44
     }
49 45
 
50 46
     case LOAD_CONFIG_ERROR: {
51
-        const { type, error } = action;
47
+        const { error, locationURL, type } = action;
52 48
 
53
-        _sendEvent(
54
-            store,
55
-            _getSymbolDescription(type),
56
-            { error: String(error) });
49
+        _sendEvent(store, _getSymbolDescription(type), {
50
+            error: String(error),
51
+            url: toURLString(locationURL)
52
+        });
57 53
         break;
58 54
     }
59 55
     }

Loading…
Cancel
Save