Poll: fix crash when voting
This commit is contained in:
parent
b648861309
commit
cb98c16011
2 changed files with 7 additions and 10 deletions
|
@ -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…
Reference in a new issue