diff options
author | Aurélien Reeves <aurelien.reeves@hiptest.net> | 2019-05-09 22:39:27 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2019-05-10 18:56:01 +0200 |
commit | 96f0747afe346f2aee358d842f8f9f77638c27a9 (patch) | |
tree | b6b31bad748c9ed434bb0bfaaeb6bbad41fd78b7 /app/javascript | |
parent | 68629f2773a056b0120b956e0cb425e73fe57cab (diff) |
[Glitch] Add confirm modal for unboosting toots
Port fe8a8f779e36e25286b6a7ddc7bcd08e2a4e2890 to glitch-soc Signed-off-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app/javascript')
-rw-r--r-- | app/javascript/flavours/glitch/containers/status_container.js | 16 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/features/ui/components/boost_modal.js | 4 |
2 files changed, 11 insertions, 9 deletions
diff --git a/app/javascript/flavours/glitch/containers/status_container.js b/app/javascript/flavours/glitch/containers/status_container.js index 60636feb4..98dc5bb87 100644 --- a/app/javascript/flavours/glitch/containers/status_container.js +++ b/app/javascript/flavours/glitch/containers/status_container.js @@ -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 })); } }, diff --git a/app/javascript/flavours/glitch/features/ui/components/boost_modal.js b/app/javascript/flavours/glitch/features/ui/components/boost_modal.js index 0a914dce2..ce7ec2479 100644 --- a/app/javascript/flavours/glitch/features/ui/components/boost_modal.js +++ b/app/javascript/flavours/glitch/features/ui/components/boost_modal.js @@ -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> ); |