about summary refs log tree commit diff
path: root/app/assets/javascripts/components/reducers
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
parent92afd296509de82e7550f67064b032db916b1f63 (diff)
Cleaning up action names and compose drawer
Diffstat (limited to 'app/assets/javascripts/components/reducers')
-rw-r--r--app/assets/javascripts/components/reducers/compose.jsx25
-rw-r--r--app/assets/javascripts/components/reducers/index.jsx8
-rw-r--r--app/assets/javascripts/components/reducers/meta.jsx4
-rw-r--r--app/assets/javascripts/components/reducers/timelines.jsx (renamed from app/assets/javascripts/components/reducers/statuses.jsx)10
4 files changed, 37 insertions, 10 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;
+  }
+}
diff --git a/app/assets/javascripts/components/reducers/index.jsx b/app/assets/javascripts/components/reducers/index.jsx
index 96c026c8c..9acbfcf46 100644
--- a/app/assets/javascripts/components/reducers/index.jsx
+++ b/app/assets/javascripts/components/reducers/index.jsx
@@ -1,8 +1,10 @@
 import { combineReducers } from 'redux-immutable';
-import statuses            from './statuses';
+import timelines           from './timelines';
 import meta                from './meta';
+import compose             from './compose';
 
 export default combineReducers({
-  statuses,
-  meta
+  timelines,
+  meta,
+  compose
 });
diff --git a/app/assets/javascripts/components/reducers/meta.jsx b/app/assets/javascripts/components/reducers/meta.jsx
index 401be435d..d65c3c36d 100644
--- a/app/assets/javascripts/components/reducers/meta.jsx
+++ b/app/assets/javascripts/components/reducers/meta.jsx
@@ -1,11 +1,11 @@
-import { SET_ACCESS_TOKEN }         from '../actions/meta';
+import { ACCESS_TOKEN_SET }         from '../actions/meta';
 import Immutable                    from 'immutable';
 
 const initialState = Immutable.Map();
 
 export default function meta(state = initialState, action) {
   switch(action.type) {
-    case SET_ACCESS_TOKEN:
+    case ACCESS_TOKEN_SET:
       return state.set('access_token', action.token);
     default:
       return state;
diff --git a/app/assets/javascripts/components/reducers/statuses.jsx b/app/assets/javascripts/components/reducers/timelines.jsx
index 9f0cb207e..2e0f70c24 100644
--- a/app/assets/javascripts/components/reducers/statuses.jsx
+++ b/app/assets/javascripts/components/reducers/timelines.jsx
@@ -1,13 +1,13 @@
-import { SET_TIMELINE, ADD_STATUS } from '../actions/statuses';
-import Immutable                    from 'immutable';
+import { TIMELINE_SET, TIMELINE_UPDATE } from '../actions/timelines';
+import Immutable                         from 'immutable';
 
 const initialState = Immutable.Map();
 
-export default function statuses(state = initialState, action) {
+export default function timelines(state = initialState, action) {
   switch(action.type) {
-    case SET_TIMELINE:
+    case TIMELINE_SET:
       return state.set(action.timeline, Immutable.fromJS(action.statuses));
-    case ADD_STATUS:
+    case TIMELINE_UPDATE:
       return state.update(action.timeline, function (list) {
         return list.unshift(Immutable.fromJS(action.status));
       });