diff --git a/frontend/src/components/Board/Card/CardFooter.tsx b/frontend/src/components/Board/Card/CardFooter.tsx index 1a321a628..d303b18b6 100644 --- a/frontend/src/components/Board/Card/CardFooter.tsx +++ b/frontend/src/components/Board/Card/CardFooter.tsx @@ -92,7 +92,7 @@ const CardFooter = React.memo( const [maxVotesReached, setMaxVotesReached] = useRecoilState(maxVotesReachedAtom); const { - handleVote: { mutate }, + handleVote: { mutate, status }, toastInfoMessage, } = useVotes(); @@ -143,7 +143,7 @@ const CardFooter = React.memo( useEffect(() => { const timer = setTimeout(() => { - if (votesData.countVotes === 0) return; + if (votesData.countVotes === 0 || status === 'loading') return; mutate({ boardId, @@ -157,14 +157,13 @@ const CardFooter = React.memo( ...prev, countVotes: 0, })); - }, 200); + }, 300); return () => clearTimeout(timer); - }, [boardId, card._id, cardItemId, mutate, socketId, votesData.countVotes]); + }, [boardId, card._id, cardItemId, mutate, socketId, status, votesData.countVotes]); - const handleDeleteVote = (event: React.MouseEvent) => { - event.stopPropagation(); - if (hideCards && createdBy?._id !== userId) return; + const handleDeleteVote = () => { + if ((hideCards && createdBy?._id !== userId) || status === 'loading') return; setVotesData((prev) => ({ ...prev, countVotes: prev.countVotes - 1, @@ -179,8 +178,8 @@ const CardFooter = React.memo( } }; - const handleAddVote = (event: React.MouseEvent) => { - event.stopPropagation(); + const handleAddVote = () => { + if (status === 'loading') return; setVotesData((prev) => ({ ...prev, countVotes: prev.countVotes + 1,