Browse Source

[Glitch] Add confirm modal for unboosting toots

Port fe8a8f779e to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
closed-social-glitch-2
Aurélien Reeves 5 years ago
committed by Thibaut Girka
parent
commit
96f0747afe
2 changed files with 11 additions and 9 deletions
  1. +8
    -8
      app/javascript/flavours/glitch/containers/status_container.js
  2. +3
    -1
      app/javascript/flavours/glitch/features/ui/components/boost_modal.js

+ 8
- 8
app/javascript/flavours/glitch/containers/status_container.js View File

@ -88,18 +88,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 }));
}
},

+ 3
- 1
app/javascript/flavours/glitch/features/ui/components/boost_modal.js View File

@ -10,6 +10,7 @@ import DisplayName from 'flavours/glitch/components/display_name';
import ImmutablePureComponent from 'react-immutable-pure-component';
const messages = defineMessages({
cancel_reblog: { id: 'status.cancel_reblog_private', defaultMessage: 'Unboost' },
reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
});
@ -52,6 +53,7 @@ export default 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'>
@ -77,7 +79,7 @@ export default 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 + <i className='fa fa-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>
);

Loading…
Cancel
Save