Simplify Redux reducer source code

This commit is contained in:
Lyubomir Marinov 2016-12-13 03:15:05 -06:00
parent 80685395ed
commit 4571a4c048
1 changed files with 20 additions and 26 deletions

View File

@ -3,20 +3,14 @@ import { ReducerRegistry } from '../base/redux';
import { LARGE_VIDEO_PARTICIPANT_CHANGED } from './actionTypes'; import { LARGE_VIDEO_PARTICIPANT_CHANGED } from './actionTypes';
const INITIAL_STATE = { ReducerRegistry.register('features/largeVideo', (state = {}, action) => {
participantId: undefined
};
ReducerRegistry.register(
'features/largeVideo',
(state = INITIAL_STATE, action) => {
switch (action.type) { switch (action.type) {
// When conference is joined, we update ID of local participant from // When conference is joined, we update ID of local participant from default
// default 'local' to real ID. However, in large video we might have // 'local' to real ID. However, in large video we might have already
// already selected 'local' as participant on stage. So in this case we // selected 'local' as participant on stage. So in this case we must update
// must update ID of participant on stage to match ID in 'participants' // ID of participant on stage to match ID in 'participants' state to avoid
// state to avoid additional changes in state and (re)renders. // additional changes in state and (re)renders.
case PARTICIPANT_ID_CHANGED: case PARTICIPANT_ID_CHANGED:
if (state.participantId === action.oldValue) { if (state.participantId === action.oldValue) {
return { return {
@ -34,4 +28,4 @@ ReducerRegistry.register(
} }
return state; return state;
}); });