You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
579 B

  1. import { connect } from 'react-redux';
  2. import { debounce } from 'lodash';
  3. import Poll from 'mastodon/components/poll';
  4. import { fetchPoll, vote } from 'mastodon/actions/polls';
  5. const mapDispatchToProps = (dispatch, { pollId }) => ({
  6. refresh: debounce(
  7. () => {
  8. dispatch(fetchPoll(pollId));
  9. },
  10. 1000,
  11. { leading: true },
  12. ),
  13. onVote (choices) {
  14. dispatch(vote(pollId, choices));
  15. },
  16. });
  17. const mapStateToProps = (state, { pollId }) => ({
  18. poll: state.getIn(['polls', pollId]),
  19. });
  20. export default connect(mapStateToProps, mapDispatchToProps)(Poll);