1
0
Fork 1
forked from fedi/mastodon
mastodon/app/assets/javascripts/components/reducers/follow.jsx

30 lines
731 B
React
Raw Normal View History

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
});
export default function follow(state = initialState, action) {
2016-09-01 13:13:02 +00:00
switch(action.type) {
case FOLLOW_CHANGE:
2016-09-01 13:13:02 +00:00
return state.set('text', action.text);
case FOLLOW_SUBMIT_REQUEST:
2016-09-01 13:13:02 +00:00
return state.set('is_submitting', true);
case FOLLOW_SUBMIT_SUCCESS:
2016-09-01 13:13:02 +00:00
return state.withMutations(map => {
map.set('text', '').set('is_submitting', false);
});
case FOLLOW_SUBMIT_FAIL:
2016-09-01 13:13:02 +00:00
return state.set('is_submitting', false);
default:
return state;
}
};