about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/actions/statuses.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-06-15 21:29:04 +0200
committerThibG <thib@sitedethib.com>2018-06-16 15:09:28 +0200
commita01faecfcb9ee3d73ba84bec43536bde0f93d1cf (patch)
treebcf6b17ca56b394b1325c0aa43da4a4d88641979 /app/javascript/flavours/glitch/actions/statuses.js
parentc08a2495589183f39cf44ac4c9b71f81dd9dacdc (diff)
[Glitch] Add redraft function
Port bd0791d800902cdbdf6666e65d201df3ec22789c to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/actions/statuses.js')
-rw-r--r--app/javascript/flavours/glitch/actions/statuses.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/actions/statuses.js b/app/javascript/flavours/glitch/actions/statuses.js
index 8b49083ac..c6d8486f9 100644
--- a/app/javascript/flavours/glitch/actions/statuses.js
+++ b/app/javascript/flavours/glitch/actions/statuses.js
@@ -23,6 +23,8 @@ export const STATUS_UNMUTE_REQUEST = 'STATUS_UNMUTE_REQUEST';
 export const STATUS_UNMUTE_SUCCESS = 'STATUS_UNMUTE_SUCCESS';
 export const STATUS_UNMUTE_FAIL    = 'STATUS_UNMUTE_FAIL';
 
+export const REDRAFT = 'REDRAFT';
+
 export function fetchStatusRequest(id, skipLoading) {
   return {
     type: STATUS_FETCH_REQUEST,
@@ -70,13 +72,26 @@ export function fetchStatusFail(id, error, skipLoading) {
   };
 };
 
-export function deleteStatus(id) {
+export function redraft(status) {
+  return {
+    type: REDRAFT,
+    status,
+  };
+};
+
+export function deleteStatus(id, withRedraft = false) {
   return (dispatch, getState) => {
+    const status = getState().getIn(['statuses', id]);
+
     dispatch(deleteStatusRequest(id));
 
     api(getState).delete(`/api/v1/statuses/${id}`).then(() => {
       dispatch(deleteStatusSuccess(id));
       dispatch(deleteFromTimelines(id));
+
+      if (withRedraft) {
+        dispatch(redraft(status));
+      }
     }).catch(error => {
       dispatch(deleteStatusFail(id, error));
     });