about summary refs log tree commit diff
path: root/app/assets/javascripts/components/reducers/compose.jsx
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-08-31 16:15:12 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-08-31 16:15:12 +0200
commit72591cc6d59d774e66d1d42af44bdc00f71f99f8 (patch)
treee2ab1fba6e9b446b92f065af920483b998a2c2ab /app/assets/javascripts/components/reducers/compose.jsx
parent92afd296509de82e7550f67064b032db916b1f63 (diff)
Cleaning up action names and compose drawer
Diffstat (limited to 'app/assets/javascripts/components/reducers/compose.jsx')
-rw-r--r--app/assets/javascripts/components/reducers/compose.jsx25
1 files changed, 25 insertions, 0 deletions
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;
+  }
+}