diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-01 15:13:02 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-01 15:13:02 +0200 |
commit | 2d57bcf1b7ea3a9df42ae7e1eb9388f978a96312 (patch) | |
tree | 2dfbfbc8e5555d8dedf2760f53824553c53655f7 /app/assets/javascripts/components/reducers | |
parent | c249ceb10c9deb468823b7e4fa2e876be5c99545 (diff) |
Preparing for follow form
Diffstat (limited to 'app/assets/javascripts/components/reducers')
-rw-r--r-- | app/assets/javascripts/components/reducers/follow.jsx | 24 | ||||
-rw-r--r-- | app/assets/javascripts/components/reducers/index.jsx | 4 |
2 files changed, 27 insertions, 1 deletions
diff --git a/app/assets/javascripts/components/reducers/follow.jsx b/app/assets/javascripts/components/reducers/follow.jsx new file mode 100644 index 000000000..348510eaf --- /dev/null +++ b/app/assets/javascripts/components/reducers/follow.jsx @@ -0,0 +1,24 @@ +import * as constants from '../actions/follow'; +import Immutable from 'immutable'; + +const initialState = Immutable.Map({ + text: '', + is_submitting: false +}); + +export default function compose(state = initialState, action) { + switch(action.type) { + case constants.FOLLOW_CHANGE: + return state.set('text', action.text); + case constants.FOLLOW_SUBMIT_REQUEST: + return state.set('is_submitting', true); + case constants.FOLLOW_SUBMIT_SUCCESS: + return state.withMutations(map => { + map.set('text', '').set('is_submitting', false); + }); + case constants.FOLLOW_SUBMIT_FAIL: + return state.set('is_submitting', false); + default: + return state; + } +} diff --git a/app/assets/javascripts/components/reducers/index.jsx b/app/assets/javascripts/components/reducers/index.jsx index 9acbfcf46..3f3e1e928 100644 --- a/app/assets/javascripts/components/reducers/index.jsx +++ b/app/assets/javascripts/components/reducers/index.jsx @@ -2,9 +2,11 @@ import { combineReducers } from 'redux-immutable'; import timelines from './timelines'; import meta from './meta'; import compose from './compose'; +import follow from './follow'; export default combineReducers({ timelines, meta, - compose + compose, + follow }); |