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,
|
||||
disabled: PropTypes.bool,
|
||||
me: SoapboxPropTypes.me,
|
||||
onOpenUnauthorizedModal: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
state = {
|
||||
|
@ -40,6 +41,7 @@ class Poll extends ImmutablePureComponent {
|
|||
};
|
||||
|
||||
_toggleOption = value => {
|
||||
if (this.props.me) {
|
||||
if (this.props.poll.get('multiple')) {
|
||||
const tmp = { ...this.state.selected };
|
||||
if (tmp[value]) {
|
||||
|
@ -53,6 +55,9 @@ class Poll extends ImmutablePureComponent {
|
|||
tmp[value] = true;
|
||||
this.setState({ selected: tmp });
|
||||
}
|
||||
} else {
|
||||
this.props.onOpenUnauthorizedModal();
|
||||
}
|
||||
}
|
||||
|
||||
handleOptionChange = ({ target: { value } }) => {
|
||||
|
|
|
@ -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);
|
||||
|
|
Ładowanie…
Reference in New Issue