From 72591cc6d59d774e66d1d42af44bdc00f71f99f8 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 31 Aug 2016 16:15:12 +0200 Subject: Cleaning up action names and compose drawer --- .../javascripts/components/reducers/compose.jsx | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 app/assets/javascripts/components/reducers/compose.jsx (limited to 'app/assets/javascripts/components/reducers/compose.jsx') diff --git a/app/assets/javascripts/components/reducers/compose.jsx b/app/assets/javascripts/components/reducers/compose.jsx new file mode 100644 index 000000000..93e0c7ebe --- /dev/null +++ b/app/assets/javascripts/components/reducers/compose.jsx @@ -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; + } +} -- cgit