From 402c19a92475014e04df91eca759225f8a89d2ac Mon Sep 17 00:00:00 2001 From: Atsushi Yamamoto Date: Mon, 29 May 2017 11:56:13 -0400 Subject: Add preference setting for delete toot modal (#3368) * Set delete_modal preference to true by default * Does not show confirmation modal if delete_modal is false * Add ja translation for preference setting page --- app/javascript/mastodon/containers/status_container.js | 15 ++++++++++----- app/javascript/mastodon/features/status/index.js | 16 +++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/mastodon/containers/status_container.js b/app/javascript/mastodon/containers/status_container.js index 141f287af..2592e9a69 100644 --- a/app/javascript/mastodon/containers/status_container.js +++ b/app/javascript/mastodon/containers/status_container.js @@ -37,6 +37,7 @@ const makeMapStateToProps = () => { status: getStatus(state, props.id), me: state.getIn(['meta', 'me']), boostModal: state.getIn(['meta', 'boost_modal']), + deleteModal: state.getIn(['meta', 'delete_modal']), autoPlayGif: state.getIn(['meta', 'auto_play_gif']), }); @@ -74,11 +75,15 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ }, onDelete (status) { - dispatch(openModal('CONFIRM', { - message: intl.formatMessage(messages.deleteMessage), - confirm: intl.formatMessage(messages.deleteConfirm), - onConfirm: () => dispatch(deleteStatus(status.get('id'))), - })); + if (!this.deleteModal) { + dispatch(deleteStatus(status.get('id'))); + } else { + dispatch(openModal('CONFIRM', { + message: intl.formatMessage(messages.deleteMessage), + confirm: intl.formatMessage(messages.deleteConfirm), + onConfirm: () => dispatch(deleteStatus(status.get('id'))), + })); + } }, onMention (account, router) { diff --git a/app/javascript/mastodon/features/status/index.js b/app/javascript/mastodon/features/status/index.js index 24cf3d108..7fc55b795 100644 --- a/app/javascript/mastodon/features/status/index.js +++ b/app/javascript/mastodon/features/status/index.js @@ -48,6 +48,7 @@ const makeMapStateToProps = () => { descendantsIds: state.getIn(['timelines', 'descendants', Number(props.params.statusId)]), me: state.getIn(['meta', 'me']), boostModal: state.getIn(['meta', 'boost_modal']), + deleteModal: state.getIn(['meta', 'delete_modal']), autoPlayGif: state.getIn(['meta', 'auto_play_gif']), }); @@ -68,6 +69,7 @@ class Status extends ImmutablePureComponent { descendantsIds: ImmutablePropTypes.list, me: PropTypes.number, boostModal: PropTypes.bool, + deleteModal: PropTypes.bool, autoPlayGif: PropTypes.bool, intl: PropTypes.object.isRequired, }; @@ -113,11 +115,15 @@ class Status extends ImmutablePureComponent { handleDeleteClick = (status) => { const { dispatch, intl } = this.props; - dispatch(openModal('CONFIRM', { - message: intl.formatMessage(messages.deleteMessage), - confirm: intl.formatMessage(messages.deleteConfirm), - onConfirm: () => dispatch(deleteStatus(status.get('id'))), - })); + if (!this.props.deleteModal) { + dispatch(deleteStatus(status.get('id'))); + } else { + dispatch(openModal('CONFIRM', { + message: intl.formatMessage(messages.deleteMessage), + confirm: intl.formatMessage(messages.deleteConfirm), + onConfirm: () => dispatch(deleteStatus(status.get('id'))), + })); + } } handleMentionClick = (account, router) => { -- cgit