Przeglądaj źródła

Simplify Redux reducer source code

master
Lyubomir Marinov 9 lat temu
rodzic
commit
4571a4c048
1 zmienionych plików z 20 dodań i 26 usunięć
  1. 20
    26
      react/features/largeVideo/reducer.js

+ 20
- 26
react/features/largeVideo/reducer.js Wyświetl plik

@@ -3,35 +3,29 @@ import { ReducerRegistry } from '../base/redux';
3 3
 
4 4
 import { LARGE_VIDEO_PARTICIPANT_CHANGED } from './actionTypes';
5 5
 
6
-const INITIAL_STATE = {
7
-    participantId: undefined
8
-};
6
+ReducerRegistry.register('features/largeVideo', (state = {}, action) => {
7
+    switch (action.type) {
9 8
 
10
-ReducerRegistry.register(
11
-    'features/largeVideo',
12
-    (state = INITIAL_STATE, action) => {
13
-        switch (action.type) {
14
-
15
-        // When conference is joined, we update ID of local participant from
16
-        // default 'local' to real ID. However, in large video we might have
17
-        // already selected 'local' as participant on stage. So in this case we
18
-        // must update ID of participant on stage to match ID in 'participants'
19
-        // state to avoid additional changes in state and (re)renders.
20
-        case PARTICIPANT_ID_CHANGED:
21
-            if (state.participantId === action.oldValue) {
22
-                return {
23
-                    ...state,
24
-                    participantId: action.newValue
25
-                };
26
-            }
27
-            break;
28
-
29
-        case LARGE_VIDEO_PARTICIPANT_CHANGED:
9
+    // When conference is joined, we update ID of local participant from default
10
+    // 'local' to real ID. However, in large video we might have already
11
+    // selected 'local' as participant on stage. So in this case we must update
12
+    // ID of participant on stage to match ID in 'participants' state to avoid
13
+    // additional changes in state and (re)renders.
14
+    case PARTICIPANT_ID_CHANGED:
15
+        if (state.participantId === action.oldValue) {
30 16
             return {
31 17
                 ...state,
32
-                participantId: action.participantId
18
+                participantId: action.newValue
33 19
             };
34 20
         }
21
+        break;
22
+
23
+    case LARGE_VIDEO_PARTICIPANT_CHANGED:
24
+        return {
25
+            ...state,
26
+            participantId: action.participantId
27
+        };
28
+    }
35 29
 
36
-        return state;
37
-    });
30
+    return state;
31
+});

Ładowanie…
Anuluj
Zapisz