瀏覽代碼

ref(base/conference): simplify code

Simplify parts of the logic introduced in
11b7144ad0.

Specificaly, using all the state change avoiding functions doesn't give us much
since we need to copy the state for sure.
master
Saúl Ibarra Corretgé 7 年之前
父節點
當前提交
bbf505c076
共有 1 個文件被更改,包括 7 次插入25 次删除
  1. 7
    25
      react/features/base/conference/reducer.js

+ 7
- 25
react/features/base/conference/reducer.js 查看文件

@@ -60,10 +60,7 @@ ReducerRegistry.register('features/base/conference', (state = {}, action) => {
60 60
         return _setDesktopSharingEnabled(state, action);
61 61
 
62 62
     case SET_FOLLOW_ME:
63
-        return {
64
-            ...state,
65
-            followMeEnabled: action.enabled
66
-        };
63
+        return set(state, 'followMeEnabled', action.enabled);
67 64
 
68 65
     case SET_PASSWORD:
69 66
         return _setPassword(state, action);
@@ -206,7 +203,7 @@ function _conferenceJoined(state, { conference }) {
206 203
  * reduction of the specified action.
207 204
  */
208 205
 function _conferenceLeftOrWillLeave(state, { conference, type }) {
209
-    let nextState = state;
206
+    const nextState = { ...state };
210 207
 
211 208
     // The redux action CONFERENCE_LEFT is the last time that we should be
212 209
     // hearing from a JitsiConference instance.
@@ -217,20 +214,14 @@ function _conferenceLeftOrWillLeave(state, { conference, type }) {
217 214
     // due clean-up like leaving the associated room, but the instance is no
218 215
     // longer the focus of the attention of the user and, consequently, the app.
219 216
     for (const p in state) {
220
-        if (p !== 'leaving' && state[p] === conference) {
221
-            nextState = set(nextState, p, undefined);
217
+        if (state[p] === conference) {
218
+            nextState[p] = undefined;
222 219
 
223 220
             switch (p) {
224 221
             case 'conference':
225
-                // XXX Clear/unset locked & password for a conference which has
226
-                // been LOCKED_LOCALLY.
227
-                delete nextState.locked;
228
-                delete nextState.password;
229
-                break;
230
-
231 222
             case 'passwordRequired':
232 223
                 // XXX Clear/unset locked & password for a conference which has
233
-                // been LOCKED_REMOTELY.
224
+                // been LOCKED_LOCALLY or LOCKED_REMOTELY.
234 225
                 delete nextState.locked;
235 226
                 delete nextState.password;
236 227
                 break;
@@ -238,15 +229,7 @@ function _conferenceLeftOrWillLeave(state, { conference, type }) {
238 229
         }
239 230
     }
240 231
 
241
-    // leaving
242
-    switch (type) {
243
-    case CONFERENCE_LEFT:
244
-        if (state.leaving === conference) {
245
-            nextState = set(nextState, 'leaving', undefined);
246
-        }
247
-        break;
248
-
249
-    case CONFERENCE_WILL_LEAVE:
232
+    if (type === CONFERENCE_WILL_LEAVE) {
250 233
         // A CONFERENCE_WILL_LEAVE is of further consequence only if it is
251 234
         // expected i.e. if the specified conference is joining or joined.
252 235
         if (conference === state.joining || conference === state.conference) {
@@ -256,9 +239,8 @@ function _conferenceLeftOrWillLeave(state, { conference, type }) {
256 239
              *
257 240
              * @type {JitsiConference}
258 241
              */
259
-            nextState = set(nextState, 'leaving', conference);
242
+            nextState.leaving = conference;
260 243
         }
261
-        break;
262 244
     }
263 245
 
264 246
     return nextState;

Loading…
取消
儲存