diff --git a/app/javascript/mastodon/components/poll.tsx b/app/javascript/mastodon/components/poll.tsx index c3ba7c97ef..6692f674d4 100644 --- a/app/javascript/mastodon/components/poll.tsx +++ b/app/javascript/mastodon/components/poll.tsx @@ -7,7 +7,6 @@ import classNames from 'classnames'; import { animated, useSpring } from '@react-spring/web'; import escapeTextContentForBrowser from 'escape-html'; -import { debounce } from 'lodash'; import CheckIcon from '@/material-icons/400-24px/check.svg?react'; import { openModal } from 'mastodon/actions/modal'; @@ -45,9 +44,7 @@ interface PollProps { disabled?: boolean; } -export const Poll: React.FC = (props) => { - const { pollId, status } = props; - +export const Poll: React.FC = ({ pollId, disabled, status }) => { // Third party hooks const poll = useAppSelector((state) => state.polls[pollId]); const identity = useIdentity(); @@ -97,12 +94,12 @@ export const Poll: React.FC = (props) => { ); }, [poll]); - const disabled = - props.disabled || Object.values(selected).every((item) => !item); + const voteDisabled = + disabled || Object.values(selected).every((item) => !item); // Event handlers const handleVote = useCallback(() => { - if (disabled) { + if (voteDisabled) { return; } @@ -120,7 +117,7 @@ export const Poll: React.FC = (props) => { }), ); } - }, [disabled, dispatch, identity, pollId, selected, status]); + }, [voteDisabled, dispatch, identity, pollId, selected, status]); const handleReveal = useCallback(() => { setRevealed(true); @@ -130,13 +127,7 @@ export const Poll: React.FC = (props) => { if (disabled) { return; } - debounce( - () => { - void dispatch(fetchPoll({ pollId })); - }, - 1000, - { leading: true }, - ); + void dispatch(fetchPoll({ pollId })); }, [disabled, dispatch, pollId]); const handleOptionChange = useCallback( @@ -181,7 +172,7 @@ export const Poll: React.FC = (props) => { {!showResults && (