Merge branch 'polls-unauthorized-modal' into 'develop'
Check if unauthorized when toggling poll options See merge request soapbox-pub/soapbox-fe!828
This commit is contained in:
commit
8634db39a5
2 changed files with 21 additions and 9 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue