Fix poll refresh button being incorrectly hidden (#34323)
Some checks failed
Check i18n / check-i18n (push) Waiting to run
Check formatting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
CSS Linting / lint (push) Has been cancelled
Bundler Audit / security (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (ruby) (push) Has been cancelled

This commit is contained in:
Claire
2025-03-31 10:21:02 +02:00
committed by GitHub
parent 70e14c1ed0
commit 33f3a4c4c8

View File

@@ -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<PollProps> = (props) => {
const { pollId, status } = props;
export const Poll: React.FC<PollProps> = ({ 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<PollProps> = (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<PollProps> = (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<PollProps> = (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<PollProps> = (props) => {
{!showResults && (
<button
className='button button-secondary'
disabled={disabled}
disabled={voteDisabled}
onClick={handleVote}
>
<FormattedMessage id='poll.vote' defaultMessage='Vote' />