diff options
Diffstat (limited to 'app/javascript/mastodon/containers/poll_container.js')
-rw-r--r-- | app/javascript/mastodon/containers/poll_container.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/app/javascript/mastodon/containers/poll_container.js b/app/javascript/mastodon/containers/poll_container.js index cd7216de7..f40ba8fac 100644 --- a/app/javascript/mastodon/containers/poll_container.js +++ b/app/javascript/mastodon/containers/poll_container.js @@ -1,8 +1,25 @@ import { connect } from 'react-redux'; +import { debounce } from 'lodash'; + import Poll from 'mastodon/components/poll'; +import { fetchPoll, vote } from 'mastodon/actions/polls'; + +const mapDispatchToProps = (dispatch, { pollId }) => ({ + refresh: debounce( + () => { + dispatch(fetchPoll(pollId)); + }, + 1000, + { leading: true }, + ), + + onVote (choices) { + dispatch(vote(pollId, choices)); + }, +}); const mapStateToProps = (state, { pollId }) => ({ poll: state.getIn(['polls', pollId]), }); -export default connect(mapStateToProps)(Poll); +export default connect(mapStateToProps, mapDispatchToProps)(Poll); |