Skip to content

Commit

Permalink
Add confirm modal for unboosting toots (mastodon#10287)
Browse files Browse the repository at this point in the history
[mastodon#3815]

Display the boost modal also when unboosting toots.
  • Loading branch information
aurelien-reeves authored and Gargron committed May 9, 2019
1 parent 21977ff commit 05a99a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 8 additions & 8 deletions app/javascript/mastodon/containers/status_container.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
},

onModalReblog (status) {
dispatch(reblog(status));
if (status.get('reblogged')) {
dispatch(unreblog(status));
} else {
dispatch(reblog(status));
}
},

onReblog (status, e) {
if (status.get('reblogged')) {
dispatch(unreblog(status));
if (e.shiftKey || !boostModal) {
this.onModalReblog(status);
} else {
if (e.shiftKey || !boostModal) {
this.onModalReblog(status);
} else {
dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
}
dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
import Icon from 'mastodon/components/icon';

const messages = defineMessages({
cancel_reblog: { id: 'status.cancel_reblog_private', defaultMessage: 'Unboost' },
reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
});

Expand Down Expand Up @@ -51,6 +52,7 @@ class BoostModal extends ImmutablePureComponent {

render () {
const { status, intl } = this.props;
const buttonText = status.get('reblogged') ? messages.cancel_reblog : messages.reblog;

return (
<div className='modal-root__modal boost-modal'>
Expand All @@ -76,7 +78,7 @@ class BoostModal extends ImmutablePureComponent {

<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 + <Icon id='retweet' /></span> }} /></div>
<Button text={intl.formatMessage(messages.reblog)} onClick={this.handleReblog} ref={this.setRef} />
<Button text={intl.formatMessage(buttonText)} onClick={this.handleReblog} ref={this.setRef} />
</div>
</div>
);
Expand Down

0 comments on commit 05a99a3

Please sign in to comment.