Add option to display a warning before boosting toots lacking media descriptions

This commit is contained in:
Thibaut Girka 2019-06-07 18:38:07 +02:00 committed by ThibG
parent d61a6271c6
commit ccfb48d3eb
5 changed files with 35 additions and 10 deletions

View file

@ -96,11 +96,16 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
}, },
onReblog (status, e) { onReblog (status, e) {
if (e.shiftKey || !boostModal) { dispatch((_, getState) => {
let state = getState();
if (state.getIn(['local_settings', 'confirm_boost_missing_media_description']) && status.get('media_attachments').some(item => !item.get('description')) && !status.get('reblogged')) {
dispatch(openModal('BOOST', { status, onReblog: this.handleModalReblog, missingMediaDescription: true }));
} else if (e.shiftKey || !boostModal) {
this.onModalReblog(status); this.onModalReblog(status);
} else { } else {
dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog })); dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
} }
});
}, },
onBookmark (status) { onBookmark (status) {

View file

@ -51,6 +51,14 @@ export default class LocalSettingsPage extends React.PureComponent {
<FormattedMessage id='settings.hicolor_privacy_icons' defaultMessage='High color privacy icons' /> <FormattedMessage id='settings.hicolor_privacy_icons' defaultMessage='High color privacy icons' />
<span className='hint'><FormattedMessage id='settings.hicolor_privacy_icons.hint' defaultMessage="Display privacy icons in bright and easily distinguishable colors" /></span> <span className='hint'><FormattedMessage id='settings.hicolor_privacy_icons.hint' defaultMessage="Display privacy icons in bright and easily distinguishable colors" /></span>
</LocalSettingsPageItem> </LocalSettingsPageItem>
<LocalSettingsPageItem
settings={settings}
item={['confirm_boost_missing_media_description']}
id='mastodon-settings--confirm_boost_missing_media_description'
onChange={onChange}
>
<FormattedMessage id='settings.confirm_boost_missing_media_description' defaultMessage='Show confirmation dialog before boosting toots lacking media descriptions' />
</LocalSettingsPageItem>
<section> <section>
<h2><FormattedMessage id='settings.notifications_opts' defaultMessage='Notifications options' /></h2> <h2><FormattedMessage id='settings.notifications_opts' defaultMessage='Notifications options' /></h2>
<LocalSettingsPageItem <LocalSettingsPageItem

View file

@ -235,13 +235,17 @@ export default class Status extends ImmutablePureComponent {
} }
handleReblogClick = (status, e) => { handleReblogClick = (status, e) => {
const { settings, dispatch } = this.props;
if (status.get('reblogged')) { if (status.get('reblogged')) {
this.props.dispatch(unreblog(status)); dispatch(unreblog(status));
} else { } else {
if ((e && e.shiftKey) || !boostModal) { if (settings.get('confirm_boost_missing_media_description') && status.get('media_attachments').some(item => !item.get('description'))) {
dispatch(openModal('BOOST', { status, onReblog: this.handleModalReblog, missingMediaDescription: true }));
} else if ((e && e.shiftKey) || !boostModal) {
this.handleModalReblog(status); this.handleModalReblog(status);
} else { } else {
this.props.dispatch(openModal('BOOST', { status, onReblog: this.handleModalReblog })); dispatch(openModal('BOOST', { status, onReblog: this.handleModalReblog }));
} }
} }
} }

View file

@ -25,6 +25,7 @@ export default class BoostModal extends ImmutablePureComponent {
status: ImmutablePropTypes.map.isRequired, status: ImmutablePropTypes.map.isRequired,
onReblog: PropTypes.func.isRequired, onReblog: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired,
missingMediaDescription: PropTypes.bool,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
}; };
@ -52,7 +53,7 @@ export default class BoostModal extends ImmutablePureComponent {
} }
render () { render () {
const { status, intl } = this.props; const { status, missingMediaDescription, intl } = this.props;
const buttonText = status.get('reblogged') ? messages.cancel_reblog : messages.reblog; const buttonText = status.get('reblogged') ? messages.cancel_reblog : messages.reblog;
return ( return (
@ -78,7 +79,13 @@ export default class BoostModal extends ImmutablePureComponent {
</div> </div>
<div className='boost-modal__action-bar'> <div className='boost-modal__action-bar'>
<div><FormattedMessage id='boost_modal.combo' defaultMessage='You can press {combo} to skip this next time' values={{ combo: <span>Shift + <i className='fa fa-retweet' /></span> }} /></div> <div>
{ missingMediaDescription ?
<FormattedMessage id='boost_modal.missing_description' defaultMessage='This toot contains some media without description' />
:
<FormattedMessage id='boost_modal.combo' defaultMessage='You can press {combo} to skip this next time' values={{ combo: <span>Shift + <i className='fa fa-retweet' /></span> }} />
}
</div>
<Button text={intl.formatMessage(buttonText)} onClick={this.handleReblog} ref={this.setRef} /> <Button text={intl.formatMessage(buttonText)} onClick={this.handleReblog} ref={this.setRef} />
</div> </div>
</div> </div>

View file

@ -15,6 +15,7 @@ const initialState = ImmutableMap({
show_reply_count : false, show_reply_count : false,
always_show_spoilers_field: false, always_show_spoilers_field: false,
confirm_missing_media_description: false, confirm_missing_media_description: false,
confirm_boost_missing_media_description: false,
confirm_before_clearing_draft: true, confirm_before_clearing_draft: true,
preselect_on_reply: true, preselect_on_reply: true,
inline_preview_cards: true, inline_preview_cards: true,