sforkowany z mirror/soapbox
Show unauthorized modal when toggling poll options
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>features-override
rodzic
916bf7a634
commit
92ee89936e
|
@ -33,6 +33,7 @@ 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 = {
|
||||||
|
@ -40,18 +41,22 @@ class Poll extends ImmutablePureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
_toggleOption = value => {
|
_toggleOption = value => {
|
||||||
if (this.props.poll.get('multiple')) {
|
if (this.props.me) {
|
||||||
const tmp = { ...this.state.selected };
|
if (this.props.poll.get('multiple')) {
|
||||||
if (tmp[value]) {
|
const tmp = { ...this.state.selected };
|
||||||
delete tmp[value];
|
if (tmp[value]) {
|
||||||
|
delete tmp[value];
|
||||||
|
} else {
|
||||||
|
tmp[value] = true;
|
||||||
|
}
|
||||||
|
this.setState({ selected: tmp });
|
||||||
} else {
|
} else {
|
||||||
|
const tmp = {};
|
||||||
tmp[value] = true;
|
tmp[value] = true;
|
||||||
|
this.setState({ selected: tmp });
|
||||||
}
|
}
|
||||||
this.setState({ selected: tmp });
|
|
||||||
} else {
|
} else {
|
||||||
const tmp = {};
|
this.props.onOpenUnauthorizedModal();
|
||||||
tmp[value] = true;
|
|
||||||
this.setState({ selected: tmp });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
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 }) => ({
|
||||||
|
@ -6,4 +7,10 @@ const mapStateToProps = (state, { pollId }) => ({
|
||||||
me: state.get('me'),
|
me: state.get('me'),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps)(Poll);
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
onOpenUnauthorizedModal() {
|
||||||
|
dispatch(openModal('UNAUTHORIZED'));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(Poll);
|
||||||
|
|
Ładowanie…
Reference in New Issue