diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-06-05 00:17:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-05 00:17:38 +0200 |
commit | bd0791d800902cdbdf6666e65d201df3ec22789c (patch) | |
tree | 3cb41294e095396df9158b5558952a1b5dc72c2e /app/javascript/mastodon/actions/statuses.js | |
parent | 5fb013878fa7cb82c887d5215b2d6c8294db6b21 (diff) |
Add redraft function (#7735)
* Add redraft function Fix #7010 * Add explicit confirmation * Add explicit confirmation message
Diffstat (limited to 'app/javascript/mastodon/actions/statuses.js')
-rw-r--r-- | app/javascript/mastodon/actions/statuses.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/javascript/mastodon/actions/statuses.js b/app/javascript/mastodon/actions/statuses.js index 849cb4f5a..3e1e5f270 100644 --- a/app/javascript/mastodon/actions/statuses.js +++ b/app/javascript/mastodon/actions/statuses.js @@ -29,6 +29,8 @@ export const STATUS_UNMUTE_FAIL = 'STATUS_UNMUTE_FAIL'; export const STATUS_REVEAL = 'STATUS_REVEAL'; export const STATUS_HIDE = 'STATUS_HIDE'; +export const REDRAFT = 'REDRAFT'; + export function fetchStatusRequest(id, skipLoading) { return { type: STATUS_FETCH_REQUEST, @@ -131,14 +133,27 @@ 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(() => { evictStatus(id); dispatch(deleteStatusSuccess(id)); dispatch(deleteFromTimelines(id)); + + if (withRedraft) { + dispatch(redraft(status)); + } }).catch(error => { dispatch(deleteStatusFail(id, error)); }); |