Kaynağa Gözat

[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 yıl önce
ebeveyn
işleme
284e4e543e

+ 6
- 0
android/README.md Dosyayı Görüntüle

@@ -241,3 +241,9 @@ The `data` HashMap contains a "url" key with the conference URL.
241 241
 Called before a conference is left.
242 242
 
243 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 Dosyayı Görüntüle

@@ -57,4 +57,11 @@ public abstract class JitsiMeetViewAdapter implements JitsiMeetViewListener {
57 57
     @Override
58 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 Dosyayı Görüntüle

@@ -58,4 +58,11 @@ public interface JitsiMeetViewListener {
58 58
      * @param data - Map with a "url" key with the conference URL.
59 59
      */
60 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 Dosyayı Görüntüle

@@ -150,3 +150,9 @@ The `data` dictionary contains a "url" key with the conference URL.
150 150
 Called before a conference is left.
151 151
 
152 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 Dosyayı Görüntüle

@@ -59,4 +59,11 @@
59 59
  */
60 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 69
 @end

+ 6
- 2
react/features/app/actions.js Dosyayı Görüntüle

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

+ 11
- 0
react/features/base/config/actionTypes.js Dosyayı Görüntüle

@@ -1,3 +1,14 @@
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 13
  * The redux action which sets the configuration represented by the feature
3 14
  * base/config. The configuration is defined and consumed by the library

+ 17
- 1
react/features/base/config/actions.js Dosyayı Görüntüle

@@ -1,6 +1,22 @@
1 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 22
  * Sets the configuration represented by the feature base/config. The

+ 11
- 0
react/features/mobile/external-api/middleware.js Dosyayı Görüntüle

@@ -10,6 +10,7 @@ import {
10 10
     CONFERENCE_WILL_LEAVE,
11 11
     JITSI_CONFERENCE_URL_KEY
12 12
 } from '../../base/conference';
13
+import { LOAD_CONFIG_ERROR } from '../../base/config';
13 14
 import { MiddlewareRegistry } from '../../base/redux';
14 15
 import { toURLString } from '../../base/util';
15 16
 
@@ -45,6 +46,16 @@ MiddlewareRegistry.register(store => next => action => {
45 46
         _sendEvent(store, name, data);
46 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 61
     return result;

Loading…
İptal
Kaydet