]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Fix not being able to vote
authorThibG <thib@sitedethib.com>
Fri, 17 Apr 2020 19:54:25 +0000 (21:54 +0200)
committerThibaut Girka <thib@sitedethib.com>
Fri, 17 Apr 2020 20:04:10 +0000 (22:04 +0200)
Port e12a5635da7de5a1c3b08b2ce420ee8a56ae4aff to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/components/poll.js
app/javascript/flavours/glitch/containers/poll_container.js

index 088d93990bc0e6064bc4f8d975ce075f0d9905de..6f57c19509abed7d5d79d6df14d539a5360343ba 100644 (file)
@@ -4,7 +4,6 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
 import ImmutablePureComponent from 'react-immutable-pure-component';
 import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
 import classNames from 'classnames';
-import { vote } from 'flavours/glitch/actions/polls';
 import Motion from 'flavours/glitch/util/optional_motion';
 import spring from 'react-motion/lib/spring';
 import escapeTextContentForBrowser from 'escape-html';
@@ -28,9 +27,9 @@ class Poll extends ImmutablePureComponent {
   static propTypes = {
     poll: ImmutablePropTypes.map,
     intl: PropTypes.object.isRequired,
-    dispatch: PropTypes.func,
     disabled: PropTypes.bool,
     refresh: PropTypes.func,
+    onVote: PropTypes.func,
   };
 
   state = {
@@ -101,7 +100,7 @@ class Poll extends ImmutablePureComponent {
       return;
     }
 
-    this.props.dispatch(vote(this.props.poll.get('id'), Object.keys(this.state.selected)));
+    this.props.onVote(Object.keys(this.state.selected));
   };
 
   handleRefresh = () => {
index b9086435474445c3235a6c437e104852a5da1325..345351cc610ab5d31542fb8cab44054fad724780 100644 (file)
@@ -2,7 +2,7 @@ import { connect } from 'react-redux';
 import { debounce } from 'lodash';
 
 import Poll from 'flavours/glitch/components/poll';
-import { fetchPoll } from 'flavours/glitch/actions/polls';
+import { fetchPoll, vote } from 'flavours/glitch/actions/polls';
 
 const mapDispatchToProps = (dispatch, { pollId }) => ({
   refresh: debounce(
@@ -12,6 +12,10 @@ const mapDispatchToProps = (dispatch, { pollId }) => ({
     1000,
     { leading: true },
   ),
+
+  onVote (choices) {
+    dispatch(vote(pollId, choices));
+  },
 });
 
 const mapStateToProps = (state, { pollId }) => ({