Poll: fix crash when voting

merge-requests/860/head
Alex Gleason 3 years ago
parent b648861309
commit cb98c16011
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -12,6 +12,7 @@ import escapeTextContentForBrowser from 'escape-html';
import emojify from 'soapbox/features/emoji/emoji';
import RelativeTimestamp from './relative_timestamp';
import Icon from 'soapbox/components/icon';
import { openModal } from 'soapbox/actions/modal';
const messages = defineMessages({
closed: { id: 'poll.closed', defaultMessage: 'Closed' },
@ -33,7 +34,6 @@ class Poll extends ImmutablePureComponent {
dispatch: PropTypes.func,
disabled: PropTypes.bool,
me: SoapboxPropTypes.me,
onOpenUnauthorizedModal: PropTypes.func.isRequired,
};
state = {
@ -56,7 +56,7 @@ class Poll extends ImmutablePureComponent {
this.setState({ selected: tmp });
}
} else {
this.props.onOpenUnauthorizedModal();
this.openUnauthorizedModal();
}
}
@ -80,6 +80,10 @@ class Poll extends ImmutablePureComponent {
this.props.dispatch(vote(this.props.poll.get('id'), Object.keys(this.state.selected)));
};
openUnauthorizedModal = () => {
this.props.dispatch(openModal('UNAUTHORIZED'));
}
handleRefresh = () => {
if (this.props.disabled) {
return;

@ -1,5 +1,4 @@
import { connect } from 'react-redux';
import { openModal } from 'soapbox/actions/modal';
import Poll from 'soapbox/components/poll';
const mapStateToProps = (state, { pollId }) => ({
@ -7,10 +6,4 @@ const mapStateToProps = (state, { pollId }) => ({
me: state.get('me'),
});
const mapDispatchToProps = (dispatch) => ({
onOpenUnauthorizedModal() {
dispatch(openModal('UNAUTHORIZED'));
},
});
export default connect(mapStateToProps, mapDispatchToProps)(Poll);
export default connect(mapStateToProps)(Poll);

Loading…
Cancel
Save