1
0
mirror of https://github.com/mastodon/mastodon synced 2024-12-13 06:08:23 +09:00
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 22:13:02 +09:00
const initialState = Immutable.Map({
text: '',
is_submitting: false
});
export default function follow(state = initialState, action) {
2016-09-01 22:13:02 +09:00
switch(action.type) {
case FOLLOW_CHANGE:
2016-09-01 22:13:02 +09:00
return state.set('text', action.text);
case FOLLOW_SUBMIT_REQUEST:
2016-09-01 22:13:02 +09:00
return state.set('is_submitting', true);
case FOLLOW_SUBMIT_SUCCESS:
2016-09-01 22:13:02 +09:00
return state.withMutations(map => {
map.set('text', '').set('is_submitting', false);
});
case FOLLOW_SUBMIT_FAIL:
2016-09-01 22:13:02 +09:00
return state.set('is_submitting', false);
default:
return state;
}
};