Browse Source

[RN] Detect errors when loading the configuration

The error is stored in the redux store in base/config so other components can
consult it. It is also broadcasted as a new event in the external API for the
SDK.
master
Saúl Ibarra Corretgé 8 years ago
parent
commit
284e4e543e

+ 6
- 0
android/README.md View File

241
 Called before a conference is left.
241
 Called before a conference is left.
242
 
242
 
243
 The `data` HashMap contains a "url" key with the conference URL.
243
 The `data` HashMap contains a "url" key with the conference URL.
244
+
245
+#### onLoadConfigError
246
+
247
+Called when loading the main configuration fails.
248
+
249
+The `data` HashMap contains a "error" key with the error.

+ 7
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetViewAdapter.java View File

57
     @Override
57
     @Override
58
     public void onConferenceWillLeave(Map<String, Object> data) {
58
     public void onConferenceWillLeave(Map<String, Object> data) {
59
     }
59
     }
60
+
61
+    /**
62
+     * {@inheritDoc}
63
+     */
64
+    @Override
65
+    public void onLoadConfigError(Map<String, Object> data) {
66
+    }
60
 }
67
 }

+ 7
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetViewListener.java View File

58
      * @param data - Map with a "url" key with the conference URL.
58
      * @param data - Map with a "url" key with the conference URL.
59
      */
59
      */
60
     void onConferenceWillLeave(Map<String, Object> data);
60
     void onConferenceWillLeave(Map<String, Object> data);
61
+
62
+    /**
63
+     * Called when loading the main configuration fails.
64
+     *
65
+     * @param data - Map with a "error" key with the error.
66
+     */
67
+    void onLoadConfigError(Map<String, Object> data);
61
 }
68
 }

+ 6
- 0
ios/README.md View File

150
 Called before a conference is left.
150
 Called before a conference is left.
151
 
151
 
152
 The `data` dictionary contains a "url" key with the conference URL.
152
 The `data` dictionary contains a "url" key with the conference URL.
153
+
154
+#### loadConfigError
155
+
156
+Called when loading the main configuration fails.
157
+
158
+The `data` dictionary contains a "error" key with the error.

+ 7
- 0
ios/sdk/src/JitsiMeetViewDelegate.h View File

59
  */
59
  */
60
 - (void) conferenceWillLeave:(NSDictionary *)data;
60
 - (void) conferenceWillLeave:(NSDictionary *)data;
61
 
61
 
62
+/**
63
+ * Called when loading the main configuration file fails.
64
+ *
65
+ * The {@code data} dictionary contains a {@code error} key with the error.
66
+ */
67
+- (void) loadConfigError:(NSDictionary *)data;
68
+
62
 @end
69
 @end

+ 6
- 2
react/features/app/actions.js View File

1
 import { setRoom } from '../base/conference';
1
 import { setRoom } from '../base/conference';
2
 import { setLocationURL } from '../base/connection';
2
 import { setLocationURL } from '../base/connection';
3
-import { setConfig } from '../base/config';
3
+import { loadConfigError, setConfig } from '../base/config';
4
 import { loadConfig } from '../base/lib-jitsi-meet';
4
 import { loadConfig } from '../base/lib-jitsi-meet';
5
 import { parseURIString } from '../base/util';
5
 import { parseURIString } from '../base/util';
6
 
6
 
66
             // certificate-related error. In which case the connection will
66
             // certificate-related error. In which case the connection will
67
             // fail later in Strophe anyway even if we use the default
67
             // fail later in Strophe anyway even if we use the default
68
             // config here.
68
             // config here.
69
+            dispatch(loadConfigError(error));
70
+
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;
69
 
74
 
70
-            // The function loadConfig will log the err.
71
             return;
75
             return;
72
         }
76
         }
73
 
77
 

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

1
+/**
2
+ * The redux action which signals the configuration couldn't be loaded due to an
3
+ * error.
4
+ *
5
+ * {
6
+ *     type: LOAD_CONFIG_ERROR,
7
+ *     error: Error
8
+ * }
9
+ */
10
+export const LOAD_CONFIG_ERROR = Symbol('LOAD_CONFIG_ERROR');
11
+
1
 /**
12
 /**
2
  * The redux action which sets the configuration represented by the feature
13
  * The redux action which sets the configuration represented by the feature
3
  * base/config. The configuration is defined and consumed by the library
14
  * base/config. The configuration is defined and consumed by the library

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

1
 /* @flow */
1
 /* @flow */
2
 
2
 
3
-import { SET_CONFIG } from './actionTypes';
3
+import { LOAD_CONFIG_ERROR, SET_CONFIG } from './actionTypes';
4
+
5
+/**
6
+ * Signals an error when loading the configuration.
7
+ *
8
+ * @param {Error} error - The error which caused the config to not be loaded.
9
+ * @returns {{
10
+ *      type: LOAD_CONFIG_ERROR,
11
+ *      error: Error
12
+ * }}
13
+ */
14
+export function loadConfigError(error: Error) {
15
+    return {
16
+        type: LOAD_CONFIG_ERROR,
17
+        error
18
+    };
19
+}
4
 
20
 
5
 /**
21
 /**
6
  * Sets the configuration represented by the feature base/config. The
22
  * Sets the configuration represented by the feature base/config. The

+ 11
- 0
react/features/mobile/external-api/middleware.js View File

10
     CONFERENCE_WILL_LEAVE,
10
     CONFERENCE_WILL_LEAVE,
11
     JITSI_CONFERENCE_URL_KEY
11
     JITSI_CONFERENCE_URL_KEY
12
 } from '../../base/conference';
12
 } from '../../base/conference';
13
+import { LOAD_CONFIG_ERROR } from '../../base/config';
13
 import { MiddlewareRegistry } from '../../base/redux';
14
 import { MiddlewareRegistry } from '../../base/redux';
14
 import { toURLString } from '../../base/util';
15
 import { toURLString } from '../../base/util';
15
 
16
 
45
         _sendEvent(store, name, data);
46
         _sendEvent(store, name, data);
46
         break;
47
         break;
47
     }
48
     }
49
+
50
+    case LOAD_CONFIG_ERROR: {
51
+        const { type, error } = action;
52
+
53
+        _sendEvent(
54
+            store,
55
+            _getSymbolDescription(type),
56
+            { error: String(error) });
57
+        break;
58
+    }
48
     }
59
     }
49
 
60
 
50
     return result;
61
     return result;

Loading…
Cancel
Save