File size: 550 Bytes
f5071ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import {
RECEIVE_COMMENTS,
RECEIVE_COMMENT,
REMOVE_COMMENT,
} from '../actions/comment_actions';
import merge from 'lodash/merge';
export default (state = {}, action) => {
Object.freeze(state);
let newState = merge({}, state);
switch (action.type) {
case RECEIVE_COMMENTS:
return action.comments;
case RECEIVE_COMMENT:
newState[action.comment.id] = action.comment;
return newState;
case REMOVE_COMMENT:
delete newState[action.commentId];
return newState;
default:
return state;
}
};
|