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.

25 lines
830 B

  1. import { COMPOSE_CHANGE, COMPOSE_SUBMIT_REQUEST, COMPOSE_SUBMIT_SUCCESS, COMPOSE_SUBMIT_FAIL } from '../actions/compose';
  2. import Immutable from 'immutable';
  3. const initialState = Immutable.Map({
  4. text: '',
  5. in_reply_to_id: null,
  6. isSubmitting: false
  7. });
  8. export default function compose(state = initialState, action) {
  9. switch(action.type) {
  10. case COMPOSE_CHANGE:
  11. return state.set('text', action.text);
  12. case COMPOSE_SUBMIT_REQUEST:
  13. return state.set('isSubmitting', true);
  14. case COMPOSE_SUBMIT_SUCCESS:
  15. return state.withMutations(map => {
  16. map.set('text', '').set('isSubmitting', false);
  17. });
  18. case COMPOSE_SUBMIT_FAIL:
  19. return state.set('isSubmitting', false);
  20. default:
  21. return state;
  22. }
  23. }