2019-03-03 22:18:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
2023-05-23 17:15:17 +02:00
|
|
|
|
2020-04-16 20:16:20 +02:00
|
|
|
import { debounce } from 'lodash';
|
|
|
|
|
2024-10-28 14:27:37 +01:00
|
|
|
import { openModal } from 'mastodon/actions/modal';
|
2020-04-17 21:54:25 +02:00
|
|
|
import { fetchPoll, vote } from 'mastodon/actions/polls';
|
2023-05-23 17:15:17 +02:00
|
|
|
import Poll from 'mastodon/components/poll';
|
2020-04-16 20:16:20 +02:00
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch, { pollId }) => ({
|
|
|
|
refresh: debounce(
|
|
|
|
() => {
|
|
|
|
dispatch(fetchPoll(pollId));
|
|
|
|
},
|
|
|
|
1000,
|
|
|
|
{ leading: true },
|
|
|
|
),
|
2020-04-17 21:54:25 +02:00
|
|
|
|
|
|
|
onVote (choices) {
|
|
|
|
dispatch(vote(pollId, choices));
|
|
|
|
},
|
2024-10-28 14:27:37 +01:00
|
|
|
|
|
|
|
onInteractionModal (type, status) {
|
|
|
|
dispatch(openModal({
|
|
|
|
modalType: 'INTERACTION',
|
|
|
|
modalProps: {
|
|
|
|
type,
|
|
|
|
accountId: status.getIn(['account', 'id']),
|
|
|
|
url: status.get('uri'),
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
}
|
2020-04-16 20:16:20 +02:00
|
|
|
});
|
2019-03-03 22:18:23 +01:00
|
|
|
|
|
|
|
const mapStateToProps = (state, { pollId }) => ({
|
|
|
|
poll: state.getIn(['polls', pollId]),
|
|
|
|
});
|
|
|
|
|
2020-04-16 20:16:20 +02:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Poll);
|