Created
August 31, 2017 18:10
-
-
Save mattraykowski/73c1cc7e6dc7f67f7fed7925217f5615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Record, List } from 'immutable'; | |
const State = Record({ | |
posts: List(), | |
collapsedComments: List(), | |
activeCategoryFilter: 'hot' | |
}); | |
export default function(state = State(), action) { | |
switch(action.type){ | |
case 'UPDATE_POSTS': | |
return state.set('posts', actions.posts); | |
case 'UPDATE_FILTERED_POSTS': | |
return state.set('filteredPosts', action.filteredPosts); | |
case 'UPDATE_ACTIVE_POST': | |
return state.set('activePost', action.activePost); | |
case 'UPDATE_POST_COMMENTS': | |
return state.set('postComments', action.postComments); | |
case 'TOGGLE_COLLAPSE': | |
return state.set('collapsedComments', action.collapsedComments); | |
case 'TOGGLE_DOMAIN_FILTER': | |
return state.set('activeDomainFilter', action.activeDomainFilter); | |
case 'TOGGLE_CATEGORY_FILTER': | |
return state.set('activeCategoryFilter', action.activeCategoryFilter); | |
default: return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment