소스 검색

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

Loading…
취소
저장