]> cat aescling's git repositories - mastodon.git/commitdiff
Allow disabling the reply confirmation dialog
authorThibaut Girka <thib@sitedethib.com>
Tue, 27 Nov 2018 17:25:51 +0000 (18:25 +0100)
committerThibG <thib@sitedethib.com>
Tue, 18 Dec 2018 20:54:34 +0000 (21:54 +0100)
app/javascript/flavours/glitch/containers/status_container.js
app/javascript/flavours/glitch/features/local_settings/page/index.js
app/javascript/flavours/glitch/features/status/index.js
app/javascript/flavours/glitch/reducers/local_settings.js

index 663bfbebc994497f3f47599ec2f48fb7e54cd1ad..f28dce609e2b677286df77bf5cee6c394300837d 100644 (file)
@@ -22,6 +22,7 @@ import { muteStatus, unmuteStatus, deleteStatus } from 'flavours/glitch/actions/
 import { initMuteModal } from 'flavours/glitch/actions/mutes';
 import { initReport } from 'flavours/glitch/actions/reports';
 import { openModal } from 'flavours/glitch/actions/modal';
+import { changeLocalSetting } from 'flavours/glitch/actions/local_settings';
 import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
 import { boostModal, favouriteModal, deleteModal } from 'flavours/glitch/util/initial_state';
 
@@ -71,10 +72,11 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
   onReply (status, router) {
     dispatch((_, getState) => {
       let state = getState();
-      if (state.getIn(['compose', 'text']).trim().length !== 0) {
+      if (state.getIn(['local_settings', 'confirm_before_clearing_draft']) && state.getIn(['compose', 'text']).trim().length !== 0) {
         dispatch(openModal('CONFIRM', {
           message: intl.formatMessage(messages.replyMessage),
           confirm: intl.formatMessage(messages.replyConfirm),
+          onDoNotAsk: () => dispatch(changeLocalSetting(['confirm_before_clearing_draft'], false)),
           onConfirm: () => dispatch(replyCompose(status, router)),
         }));
       } else {
index 6defdfbb667ea11d6d72711ccf41cb5d3edc1d02..0b607a05d034681e4b9e36b90eee519f551197c7 100644 (file)
@@ -126,6 +126,14 @@ export default class LocalSettingsPage extends React.PureComponent {
         >
           <FormattedMessage id='settings.confirm_missing_media_description' defaultMessage='Show confirmation dialog before sending toots lacking media descriptions' />
         </LocalSettingsPageItem>
+        <LocalSettingsPageItem
+          settings={settings}
+          item={['confirm_before_clearing_draft']}
+          id='mastodon-settings--confirm_before_clearing_draft'
+          onChange={onChange}
+        >
+          <FormattedMessage id='settings.confirm_before_clearing_draft' defaultMessage='Show confirmation dialog before clearing draft' />
+        </LocalSettingsPageItem>
         <LocalSettingsPageItem
           settings={settings}
           item={['side_arm']}
index d2d5a05c8090093b27bb0d9c7a0a4dc702a4499e..aa508c4832db40ea09f83eabd4ae1aae976a4fc6 100644 (file)
@@ -24,6 +24,7 @@ import {
   mentionCompose,
   directCompose,
 } from 'flavours/glitch/actions/compose';
+import { changeLocalSetting } from 'flavours/glitch/actions/local_settings';
 import { blockAccount } from 'flavours/glitch/actions/accounts';
 import { muteStatus, unmuteStatus, deleteStatus } from 'flavours/glitch/actions/statuses';
 import { initMuteModal } from 'flavours/glitch/actions/mutes';
@@ -98,7 +99,7 @@ const makeMapStateToProps = () => {
       ancestorsIds,
       descendantsIds,
       settings: state.get('local_settings'),
-      askReplyConfirmation: state.getIn(['compose', 'text']).trim().length !== 0,
+      askReplyConfirmation: state.getIn(['local_settings', 'confirm_before_clearing_draft']) && state.getIn(['compose', 'text']).trim().length !== 0,
     };
   };
 
@@ -196,6 +197,7 @@ export default class Status extends ImmutablePureComponent {
       dispatch(openModal('CONFIRM', {
         message: intl.formatMessage(messages.replyMessage),
         confirm: intl.formatMessage(messages.replyConfirm),
+        onDoNotAsk: () => dispatch(changeLocalSetting(['confirm_before_clearing_draft'], false)),
         onConfirm: () => dispatch(replyCompose(status, this.context.router.history)),
       }));
     } else {
index bf42810e9202e9375b2c532d3d6b4e2ea8461479..15239f28ee5605655fa6262bf8b23326ab7a16d1 100644 (file)
@@ -14,6 +14,7 @@ const initialState = ImmutableMap({
   show_reply_count : false,
   always_show_spoilers_field: false,
   confirm_missing_media_description: false,
+  confirm_before_clearing_draft: true,
   preselect_on_reply: true,
   inline_preview_cards: true,
   content_warnings : ImmutableMap({