Selaa lähdekoodia

ref(base/connection): conferenceFailed error argument

Introduce ConnectionFailedError type.
j8
paweldomas 7 vuotta sitten
vanhempi
commit
a9ee5944e1

+ 6
- 1
connection.js Näytä tiedosto

@@ -102,7 +102,12 @@ function connect(id, password, roomName) {
102 102
         /* eslint-enable max-params */
103 103
             APP.store.dispatch(
104 104
                 connectionFailed(
105
-                    connection, error, message, credentials, details));
105
+                    connection, {
106
+                        credentials,
107
+                        details,
108
+                        message,
109
+                        name: error
110
+                    }));
106 111
 
107 112
             if (isFatalJitsiConnectionError(error)) {
108 113
                 connection.removeEventListener(

+ 2
- 5
react/features/authentication/actions.js Näytä tiedosto

@@ -4,6 +4,7 @@ import { appNavigate } from '../app';
4 4
 import { checkIfCanJoin, conferenceLeft } from '../base/conference';
5 5
 import { connectionFailed } from '../base/connection';
6 6
 import { openDialog } from '../base/dialog';
7
+import { set } from '../base/redux';
7 8
 
8 9
 import {
9 10
     CANCEL_LOGIN,
@@ -89,11 +90,7 @@ export function cancelLogin() {
89 90
             && dispatch(
90 91
                 connectionFailed(
91 92
                     passwordRequired,
92
-                    error && error.name,
93
-                    error && error.message,
94
-                    error && error.credentials,
95
-                    error && error.details,
96
-                    /* recoverable */ false));
93
+                    set(error, 'recoverable', false)));
97 94
     };
98 95
 }
99 96
 

+ 67
- 32
react/features/base/connection/actions.native.js Näytä tiedosto

@@ -15,6 +15,53 @@ import {
15 15
     SET_LOCATION_URL
16 16
 } from './actionTypes';
17 17
 
18
+/**
19
+ * The error structure passed to the {@link connectionFailed} action.
20
+ *
21
+ * Note there was an intention to make the error resemble an Error instance (to
22
+ * the extent that jitsi-meet needs it).
23
+ */
24
+export type ConnectionFailedError = {
25
+
26
+    /**
27
+     * The invalid credentials that were used to authenticate and the
28
+     * authentication failed.
29
+     */
30
+    credentials?: {
31
+
32
+        /**
33
+         * The XMPP user's ID.
34
+         */
35
+        jid: string,
36
+
37
+        /**
38
+         * The XMPP user's password.
39
+         */
40
+        password: string
41
+    },
42
+
43
+    /**
44
+     * The details about the connection failed event.
45
+     */
46
+    details?: string,
47
+
48
+    /**
49
+     * Error message.
50
+     */
51
+    message?: string,
52
+
53
+    /**
54
+     * One of {@link JitsiConnectionError} constants (defined in
55
+     * lib-jitsi-meet).
56
+     */
57
+    name: string,
58
+
59
+    /**
60
+     * Indicates whether this event is recoverable or not.
61
+     */
62
+    recoverable?: boolean
63
+}
64
+
18 65
 /**
19 66
  * Opens new connection.
20 67
  *
@@ -89,10 +136,18 @@ export function connect(id: ?string, password: ?string) {
89 136
          * @private
90 137
          * @returns {void}
91 138
          */
92
-        function _onConnectionFailed(err, msg, credentials) {
139
+        function _onConnectionFailed(
140
+                err: string, msg: string, credentials: Object) {
93 141
             unsubscribe();
94 142
             console.error('CONNECTION FAILED:', err, msg);
95
-            dispatch(connectionFailed(connection, err, msg, credentials));
143
+            dispatch(
144
+                connectionFailed(
145
+                    connection, {
146
+                        credentials,
147
+                        name: err,
148
+                        message: msg
149
+                    }
150
+                ));
96 151
         }
97 152
 
98 153
         /**
@@ -167,54 +222,34 @@ export function connectionEstablished(connection: Object) {
167 222
     };
168 223
 }
169 224
 
170
-/* eslint-disable max-params */
171
-
172 225
 /**
173 226
  * Create an action for when the signaling connection could not be created.
174 227
  *
175 228
  * @param {JitsiConnection} connection - The JitsiConnection which failed.
176
- * @param {string} error - Error.
177
- * @param {string} [message] - Error message.
178
- * @param {Object} [credentials] - The invalid credentials that failed
179
- * the authentication.
180
- * @param {Object} [details] - The details about the connection failed event.
181
- * @param {boolean} [recoverable] - Indicates whether this event is recoverable
182
- * or not.
229
+ * @param {ConnectionFailedError} error - Error.
183 230
  * @public
184 231
  * @returns {{
185 232
  *     type: CONNECTION_FAILED,
186 233
  *     connection: JitsiConnection,
187
- *     error: Object
234
+ *     error: ConnectionFailedError
188 235
  * }}
189 236
  */
190 237
 export function connectionFailed(
191 238
         connection: Object,
192
-        error: string,
193
-        message: ?string,
194
-        credentials: ?Object,
195
-        details: ?Object,
196
-        recoverable: ?boolean) {
239
+        error: ConnectionFailedError) {
240
+    const { credentials } = error;
241
+
242
+    if (credentials && !Object.keys(credentials).length) {
243
+        error.credentials = undefined;
244
+    }
245
+
197 246
     return {
198 247
         type: CONNECTION_FAILED,
199 248
         connection,
200
-
201
-        // Make the error resemble an Error instance (to the extent that
202
-        // jitsi-meet needs it).
203
-        error: {
204
-            credentials:
205
-                credentials && Object.keys(credentials).length
206
-                    ? credentials
207
-                    : undefined,
208
-            message,
209
-            name: error,
210
-            details,
211
-            recoverable
212
-        }
249
+        error
213 250
     };
214 251
 }
215 252
 
216
-/* eslint-enable max-params */
217
-
218 253
 /**
219 254
  * Constructs options to be passed to the constructor of {@code JitsiConnection}
220 255
  * based on the redux state.

+ 3
- 1
react/features/base/connection/reducer.js Näytä tiedosto

@@ -13,6 +13,8 @@ import {
13 13
     SET_LOCATION_URL
14 14
 } from './actionTypes';
15 15
 
16
+import type { ConnectionFailedError } from './actions.native';
17
+
16 18
 /**
17 19
  * Reduces the Redux actions of the feature base/connection.
18 20
  */
@@ -100,7 +102,7 @@ function _connectionFailed(
100 102
         state: Object,
101 103
         { connection, error }: {
102 104
             connection: Object,
103
-            error: Object | string
105
+            error: ConnectionFailedError
104 106
         }) {
105 107
 
106 108
     // The current (similar to getCurrentConference in

Loading…
Peruuta
Tallenna