2016-09-19 21:25:59 +00:00
|
|
|
import {
|
|
|
|
FOLLOW_CHANGE,
|
|
|
|
FOLLOW_SUBMIT_REQUEST,
|
|
|
|
FOLLOW_SUBMIT_SUCCESS,
|
|
|
|
FOLLOW_SUBMIT_FAIL
|
|
|
|
} from '../actions/follow';
|
|
|
|
import Immutable from 'immutable';
|
2016-09-01 13:13:02 +00:00
|
|
|
|
|
|
|
const initialState = Immutable.Map({
|
|
|
|
text: '',
|
|
|
|
is_submitting: false
|
|
|
|
});
|
|
|
|
|
2016-09-19 21:25:59 +00:00
|
|
|
export default function follow(state = initialState, action) {
|
2016-09-01 13:13:02 +00:00
|
|
|
switch(action.type) {
|
2016-09-19 21:25:59 +00:00
|
|
|
case FOLLOW_CHANGE:
|
2016-09-01 13:13:02 +00:00
|
|
|
return state.set('text', action.text);
|
2016-09-19 21:25:59 +00:00
|
|
|
case FOLLOW_SUBMIT_REQUEST:
|
2016-09-01 13:13:02 +00:00
|
|
|
return state.set('is_submitting', true);
|
2016-09-19 21:25:59 +00:00
|
|
|
case FOLLOW_SUBMIT_SUCCESS:
|
2016-09-01 13:13:02 +00:00
|
|
|
return state.withMutations(map => {
|
|
|
|
map.set('text', '').set('is_submitting', false);
|
|
|
|
});
|
2016-09-19 21:25:59 +00:00
|
|
|
case FOLLOW_SUBMIT_FAIL:
|
2016-09-01 13:13:02 +00:00
|
|
|
return state.set('is_submitting', false);
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2016-09-12 17:20:55 +00:00
|
|
|
};
|