about summary refs log tree commit diff
path: root/app/assets/javascripts/components/reducers/follow.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/components/reducers/follow.jsx')
-rw-r--r--app/assets/javascripts/components/reducers/follow.jsx24
1 files changed, 24 insertions, 0 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;
+  }
+}