You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
731 B

  1. import {
  2. FOLLOW_CHANGE,
  3. FOLLOW_SUBMIT_REQUEST,
  4. FOLLOW_SUBMIT_SUCCESS,
  5. FOLLOW_SUBMIT_FAIL
  6. } from '../actions/follow';
  7. import Immutable from 'immutable';
  8. const initialState = Immutable.Map({
  9. text: '',
  10. is_submitting: false
  11. });
  12. export default function follow(state = initialState, action) {
  13. switch(action.type) {
  14. case FOLLOW_CHANGE:
  15. return state.set('text', action.text);
  16. case FOLLOW_SUBMIT_REQUEST:
  17. return state.set('is_submitting', true);
  18. case FOLLOW_SUBMIT_SUCCESS:
  19. return state.withMutations(map => {
  20. map.set('text', '').set('is_submitting', false);
  21. });
  22. case FOLLOW_SUBMIT_FAIL:
  23. return state.set('is_submitting', false);
  24. default:
  25. return state;
  26. }
  27. };