mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-15 04:34:00 -05:00
26 lines
830 B
React
26 lines
830 B
React
|
import { COMPOSE_CHANGE, COMPOSE_SUBMIT_REQUEST, COMPOSE_SUBMIT_SUCCESS, COMPOSE_SUBMIT_FAIL } from '../actions/compose';
|
||
|
import Immutable from 'immutable';
|
||
|
|
||
|
const initialState = Immutable.Map({
|
||
|
text: '',
|
||
|
in_reply_to_id: null,
|
||
|
isSubmitting: false
|
||
|
});
|
||
|
|
||
|
export default function compose(state = initialState, action) {
|
||
|
switch(action.type) {
|
||
|
case COMPOSE_CHANGE:
|
||
|
return state.set('text', action.text);
|
||
|
case COMPOSE_SUBMIT_REQUEST:
|
||
|
return state.set('isSubmitting', true);
|
||
|
case COMPOSE_SUBMIT_SUCCESS:
|
||
|
return state.withMutations(map => {
|
||
|
map.set('text', '').set('isSubmitting', false);
|
||
|
});
|
||
|
case COMPOSE_SUBMIT_FAIL:
|
||
|
return state.set('isSubmitting', false);
|
||
|
default:
|
||
|
return state;
|
||
|
}
|
||
|
}
|