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