From 72591cc6d59d774e66d1d42af44bdc00f71f99f8 Mon Sep 17 00:00:00 2001
From: Eugen Rochko <eugen@zeonfederated.com>
Date: Wed, 31 Aug 2016 16:15:12 +0200
Subject: Cleaning up action names and compose drawer

---
 .../javascripts/components/actions/compose.jsx     | 49 ++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 app/assets/javascripts/components/actions/compose.jsx

(limited to 'app/assets/javascripts/components/actions/compose.jsx')

diff --git a/app/assets/javascripts/components/actions/compose.jsx b/app/assets/javascripts/components/actions/compose.jsx
new file mode 100644
index 000000000..614ed1a89
--- /dev/null
+++ b/app/assets/javascripts/components/actions/compose.jsx
@@ -0,0 +1,49 @@
+import api from '../api'
+
+export const COMPOSE_CHANGE         = 'COMPOSE_CHANGE';
+export const COMPOSE_SUBMIT         = 'COMPOSE_SUBMIT';
+export const COMPOSE_SUBMIT_REQUEST = 'COMPOSE_SUBMIT_REQUEST';
+export const COMPOSE_SUBMIT_SUCCESS = 'COMPOSE_SUBMIT_SUCCESS';
+export const COMPOSE_SUBMIT_FAIL    = 'COMPOSE_SUBMIT_FAIL';
+
+export function changeCompose(text) {
+  return {
+    type: COMPOSE_CHANGE,
+    text: text
+  };
+}
+
+export function submitCompose() {
+  return function (dispatch, getState) {
+    dispatch(submitComposeRequest());
+
+    api(getState).post('/api/statuses', {
+      status: getState().getIn(['compose', 'text'], ''),
+      in_reply_to_id: getState().getIn(['compose', 'in_reply_to_id'], null)
+    }).then(function (response) {
+      dispatch(submitComposeSuccess(response.data));
+    }).catch(function (error) {
+      dispatch(submitComposeFail(error));
+    });
+  };
+}
+
+export function submitComposeRequest() {
+  return {
+    type: COMPOSE_SUBMIT_REQUEST
+  };
+}
+
+export function submitComposeSuccess(response) {
+  return {
+    type: COMPOSE_SUBMIT_SUCCESS
+  };
+}
+
+export function submitComposeFail(error) {
+  return {
+    type: COMPOSE_SUBMIT_FAIL,
+    error: error
+  };
+}
+
-- 
cgit 

