diff --git a/app/soapbox/components/poll.js b/app/soapbox/components/poll.js index 795b87fbd..3f10cfee1 100644 --- a/app/soapbox/components/poll.js +++ b/app/soapbox/components/poll.js @@ -33,6 +33,7 @@ class Poll extends ImmutablePureComponent { dispatch: PropTypes.func, disabled: PropTypes.bool, me: SoapboxPropTypes.me, + onOpenUnauthorizedModal: PropTypes.func.isRequired, }; state = { @@ -40,18 +41,22 @@ class Poll extends ImmutablePureComponent { }; _toggleOption = value => { - if (this.props.poll.get('multiple')) { - const tmp = { ...this.state.selected }; - if (tmp[value]) { - delete tmp[value]; + if (this.props.me) { + if (this.props.poll.get('multiple')) { + const tmp = { ...this.state.selected }; + if (tmp[value]) { + delete tmp[value]; + } else { + tmp[value] = true; + } + this.setState({ selected: tmp }); } else { + const tmp = {}; tmp[value] = true; + this.setState({ selected: tmp }); } - this.setState({ selected: tmp }); } else { - const tmp = {}; - tmp[value] = true; - this.setState({ selected: tmp }); + this.props.onOpenUnauthorizedModal(); } } diff --git a/app/soapbox/containers/poll_container.js b/app/soapbox/containers/poll_container.js index dc35964f5..55f14e1b2 100644 --- a/app/soapbox/containers/poll_container.js +++ b/app/soapbox/containers/poll_container.js @@ -1,4 +1,5 @@ import { connect } from 'react-redux'; +import { openModal } from 'soapbox/actions/modal'; import Poll from 'soapbox/components/poll'; const mapStateToProps = (state, { pollId }) => ({ @@ -6,4 +7,10 @@ const mapStateToProps = (state, { pollId }) => ({ me: state.get('me'), }); -export default connect(mapStateToProps)(Poll); +const mapDispatchToProps = (dispatch) => ({ + onOpenUnauthorizedModal() { + dispatch(openModal('UNAUTHORIZED')); + }, +}); + +export default connect(mapStateToProps, mapDispatchToProps)(Poll);