about summary refs log tree commit diff
path: root/app/javascript/mastodon/containers
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-10-05 18:44:44 +0200
committerEugen Rochko <eugen@zeonfederated.com>2018-10-05 18:44:44 +0200
commit42aecb4c13a8edce014a76f2ca38baac0084b5bb (patch)
tree9b728e6a62a944f157c963b1f6b1612fd9fd4352 /app/javascript/mastodon/containers
parent028ad4124cf1fdb28f5cf11bd7080e7a63f2f99e (diff)
Add a confirmation dialog when hitting reply and the compose box isn't empty (#8893)
* Add a confirmation dialog when hitting reply and the compose box isn't empty

Fixes #878

* Performance improvement
Diffstat (limited to 'app/javascript/mastodon/containers')
-rw-r--r--app/javascript/mastodon/containers/status_container.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/app/javascript/mastodon/containers/status_container.js b/app/javascript/mastodon/containers/status_container.js
index bbc0d5e96..b3555c76e 100644
--- a/app/javascript/mastodon/containers/status_container.js
+++ b/app/javascript/mastodon/containers/status_container.js
@@ -36,6 +36,8 @@ const messages = defineMessages({
   redraftConfirm: { id: 'confirmations.redraft.confirm', defaultMessage: 'Delete & redraft' },
   redraftMessage: { id: 'confirmations.redraft.message', defaultMessage: 'Are you sure you want to delete this status and re-draft it? Favourites and boosts will be lost, and replies to the original post will be orphaned.' },
   blockConfirm: { id: 'confirmations.block.confirm', defaultMessage: 'Block' },
+  replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' },
+  replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' },
 });
 
 const makeMapStateToProps = () => {
@@ -51,7 +53,18 @@ const makeMapStateToProps = () => {
 const mapDispatchToProps = (dispatch, { intl }) => ({
 
   onReply (status, router) {
-    dispatch(replyCompose(status, router));
+    dispatch((_, getState) => {
+      let state = getState();
+      if (state.getIn(['compose', 'text']).trim().length !== 0) {
+        dispatch(openModal('CONFIRM', {
+          message: intl.formatMessage(messages.replyMessage),
+          confirm: intl.formatMessage(messages.replyConfirm),
+          onConfirm: () => dispatch(replyCompose(status, router)),
+        }));
+      } else {
+        dispatch(replyCompose(status, router));
+      }
+    });
   },
 
   onModalReblog (status) {