diff options
author | Gurgen Hayrapetyan <info.gurgen@gmail.com> | 2020-04-16 22:16:20 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-16 20:16:20 +0200 |
commit | ab8d7c0680d7f75826277be4c8eea1ebd396be8a (patch) | |
tree | 33f11af647caf69c02799440adc1c4f90a4ef0a1 /app/javascript/mastodon/containers/poll_container.js | |
parent | 04c8d825f6a70b48216b7b78e59068931f9231b2 (diff) |
Fix Poll fetchPoll action not being debounced. (#13485)
* Fix Poll fetchPoll action not being debounced. * Fix unused import in the Poll component
Diffstat (limited to 'app/javascript/mastodon/containers/poll_container.js')
-rw-r--r-- | app/javascript/mastodon/containers/poll_container.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/app/javascript/mastodon/containers/poll_container.js b/app/javascript/mastodon/containers/poll_container.js index cd7216de7..1c2e8d2a7 100644 --- a/app/javascript/mastodon/containers/poll_container.js +++ b/app/javascript/mastodon/containers/poll_container.js @@ -1,8 +1,21 @@ import { connect } from 'react-redux'; +import { debounce } from 'lodash'; + import Poll from 'mastodon/components/poll'; +import { fetchPoll } from 'mastodon/actions/polls'; + +const mapDispatchToProps = (dispatch, { pollId }) => ({ + refresh: debounce( + () => { + dispatch(fetchPoll(pollId)); + }, + 1000, + { leading: true }, + ), +}); const mapStateToProps = (state, { pollId }) => ({ poll: state.getIn(['polls', pollId]), }); -export default connect(mapStateToProps)(Poll); +export default connect(mapStateToProps, mapDispatchToProps)(Poll); |