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 emojify from 'soapbox/features/emoji/emoji';
|
||||||
import RelativeTimestamp from './relative_timestamp';
|
import RelativeTimestamp from './relative_timestamp';
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
|
import { openModal } from 'soapbox/actions/modal';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
closed: { id: 'poll.closed', defaultMessage: 'Closed' },
|
closed: { id: 'poll.closed', defaultMessage: 'Closed' },
|
||||||
|
@ -33,7 +34,6 @@ class Poll extends ImmutablePureComponent {
|
||||||
dispatch: PropTypes.func,
|
dispatch: PropTypes.func,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
me: SoapboxPropTypes.me,
|
me: SoapboxPropTypes.me,
|
||||||
onOpenUnauthorizedModal: PropTypes.func.isRequired,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -56,7 +56,7 @@ class Poll extends ImmutablePureComponent {
|
||||||
this.setState({ selected: tmp });
|
this.setState({ selected: tmp });
|
||||||
}
|
}
|
||||||
} else {
|
} 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)));
|
this.props.dispatch(vote(this.props.poll.get('id'), Object.keys(this.state.selected)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
openUnauthorizedModal = () => {
|
||||||
|
this.props.dispatch(openModal('UNAUTHORIZED'));
|
||||||
|
}
|
||||||
|
|
||||||
handleRefresh = () => {
|
handleRefresh = () => {
|
||||||
if (this.props.disabled) {
|
if (this.props.disabled) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { openModal } from 'soapbox/actions/modal';
|
|
||||||
import Poll from 'soapbox/components/poll';
|
import Poll from 'soapbox/components/poll';
|
||||||
|
|
||||||
const mapStateToProps = (state, { pollId }) => ({
|
const mapStateToProps = (state, { pollId }) => ({
|
||||||
|
@ -7,10 +6,4 @@ const mapStateToProps = (state, { pollId }) => ({
|
||||||
me: state.get('me'),
|
me: state.get('me'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
export default connect(mapStateToProps)(Poll);
|
||||||
onOpenUnauthorizedModal() {
|
|
||||||
dispatch(openModal('UNAUTHORIZED'));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(Poll);
|
|
||||||
|
|
Loading…
Reference in a new issue