Преглед изворни кода

feat(room-lock): hide dialog when conference fails

j8
Lyubo Marinov пре 7 година
родитељ
комит
b93bac5aa9
1 измењених фајлова са 40 додато и 27 уклоњено
  1. 40
    27
      react/features/room-lock/middleware.js

+ 40
- 27
react/features/room-lock/middleware.js Прегледај датотеку

21
  * Middleware that captures conference failed and checks for password required
21
  * Middleware that captures conference failed and checks for password required
22
  * error and requests a dialog for user to enter password.
22
  * error and requests a dialog for user to enter password.
23
  *
23
  *
24
- * @param {Store} store - Redux store.
24
+ * @param {Store} store - The redux store.
25
  * @returns {Function}
25
  * @returns {Function}
26
  */
26
  */
27
 MiddlewareRegistry.register(store => next => action => {
27
 MiddlewareRegistry.register(store => next => action => {
28
     switch (action.type) {
28
     switch (action.type) {
29
-    case CONFERENCE_FAILED: {
30
-        const { conference, error } = action;
31
-
32
-        if (conference
33
-                && error.name === JitsiConferenceErrors.PASSWORD_REQUIRED) {
34
-            // XXX The feature room-lock affords recovery after
35
-            // CONFERENCE_FAILED caused by
36
-            // JitsiConferenceErrors.PASSWORD_REQUIRED.
37
-            if (typeof error.recoverable === 'undefined') {
38
-                error.recoverable = true;
39
-            }
40
-            if (error.recoverable) {
41
-                store.dispatch(_openPasswordRequiredPrompt(conference));
42
-            }
43
-        } else {
44
-            store.dispatch(hideDialog(PasswordRequiredPrompt));
45
-            store.dispatch(hideDialog(RoomLockPrompt));
46
-        }
47
-        break;
48
-    }
29
+    case CONFERENCE_FAILED:
30
+        return _conferenceFailed(store, next, action);
49
 
31
 
50
     case LOCK_STATE_CHANGED:
32
     case LOCK_STATE_CHANGED:
51
         // TODO Remove this logic when all components interested in the lock
33
         // TODO Remove this logic when all components interested in the lock
62
     return next(action);
44
     return next(action);
63
 });
45
 });
64
 
46
 
47
+/**
48
+ * Handles errors that occur when a conference fails.
49
+ *
50
+ * @param {Store} store - The redux store in which the specified action is being
51
+ * dispatched.
52
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
53
+ * specified action to the specified store.
54
+ * @param {Action} action - The redux action {@code CONFERENCE_FAILED} which
55
+ * specifies the details associated with the error and the failed conference.
56
+ * @private
57
+ * @returns {*}
58
+ */
59
+function _conferenceFailed({ dispatch }, next, action) {
60
+    const { conference, error } = action;
61
+
62
+    if (conference && error.name === JitsiConferenceErrors.PASSWORD_REQUIRED) {
63
+        // XXX The feature room-lock affords recovery after CONFERENCE_FAILED
64
+        // caused by JitsiConferenceErrors.PASSWORD_REQUIRED.
65
+        if (typeof error.recoverable === 'undefined') {
66
+            error.recoverable = true;
67
+        }
68
+        if (error.recoverable) {
69
+            dispatch(_openPasswordRequiredPrompt(conference));
70
+        }
71
+    } else {
72
+        dispatch(hideDialog(PasswordRequiredPrompt));
73
+        dispatch(hideDialog(RoomLockPrompt));
74
+    }
75
+
76
+    return next(action);
77
+}
78
+
65
 /**
79
 /**
66
  * Handles errors that occur when a password fails to be set.
80
  * Handles errors that occur when a password fails to be set.
67
  *
81
  *
68
- * @param {Store} store - The Redux store in which the specified action is being
82
+ * @param {Store} store - The redux store in which the specified action is being
69
  * dispatched.
83
  * dispatched.
70
- * @param {Dispatch} next - The Redux dispatch function to dispatch the
84
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
71
  * specified action to the specified store.
85
  * specified action to the specified store.
72
- * @param {Action} action - The Redux action SET_PASSWORD_ERROR which has the
73
- * error type that should be handled.
86
+ * @param {Action} action - The redux action {@code SET_PASSWORD_ERROR} which
87
+ * has the error type that should be handled.
74
  * @private
88
  * @private
75
- * @returns {Object} The new state that is the result of the reduction of the
76
- * specified action.
89
+ * @returns {*}
77
  */
90
  */
78
 function _setPasswordFailed(store, next, action) {
91
 function _setPasswordFailed(store, next, action) {
79
     if (typeof APP !== 'undefined') {
92
     if (typeof APP !== 'undefined') {

Loading…
Откажи
Сачувај