Cleaning up action names and compose drawer
This commit is contained in:
parent
92afd29650
commit
72591cc6d5
29 changed files with 468 additions and 151 deletions
25
app/assets/javascripts/components/reducers/compose.jsx
Normal file
25
app/assets/javascripts/components/reducers/compose.jsx
Normal file
|
@ -0,0 +1,25 @@
|
|||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue