viewReducer.js 531 B

1234567891011121314151617181920212223242526
  1. import { SET_VIEW, SET_SUB_VIEW } from '../actions/types'
  2. import { WELCOME, SONG_LIST } from '../views'
  3. const initialState = {
  4. previousView: SONG_LIST,
  5. view: WELCOME,
  6. subView: 'list'
  7. }
  8. export default function(state = initialState, action) {
  9. switch(action.type) {
  10. case SET_VIEW:
  11. return {
  12. ...state,
  13. previousView: state.view,
  14. view: action.payload,
  15. }
  16. case SET_SUB_VIEW:
  17. return {
  18. ...state,
  19. subView: action.payload
  20. }
  21. default:
  22. return state
  23. }
  24. }