diff --git a/src/components/Game/MyCards.tsx b/src/components/Game/MyCards.tsx index f33edf0..28e7e78 100644 --- a/src/components/Game/MyCards.tsx +++ b/src/components/Game/MyCards.tsx @@ -34,11 +34,6 @@ import { } from "../../caches/AutoPlaySlice" import parseError from "../../utils/ErrorUtils" -interface DoubleClickTracker { - time: number - card: string -} - const MyCards: React.FC = () => { const dispatch = useAppDispatch() const gameId = useAppSelector(getGameId) @@ -51,9 +46,6 @@ const MyCards: React.FC = () => { const { enqueueSnackbar } = useSnackbar() - const [doubleClickTracker, updateDoubleClickTracker] = - useState() - const selectedCards = useAppSelector(getSelectedCards) const playButtonEnabled = useMemo( @@ -85,7 +77,10 @@ const MyCards: React.FC = () => { ) const handleSelectCard = useCallback( - (card: SelectableCard) => { + ( + card: SelectableCard, + event: React.MouseEvent, + ) => { if (!cardsSelectable || card.name === BLANK_CARD.name) { return } @@ -95,24 +90,17 @@ const MyCards: React.FC = () => { if (autoPlayCard === card.name) { dispatch(clearAutoPlay()) dispatch(clearSelectedCards()) - } else if ( - doubleClickTracker?.card === card.name && - Date.now() - doubleClickTracker.time < 500 - ) { + } else if (event.detail === 2) { dispatch(toggleAutoPlay(card)) } else { dispatch(toggleUniqueSelect(card)) dispatch(clearAutoPlay()) - updateDoubleClickTracker({ - card: card.name, - time: Date.now(), - }) } } else { dispatch(toggleSelect(card)) } }, - [round, myCards, autoPlayCard, doubleClickTracker], + [round, myCards, autoPlayCard], ) const handleOnDragEnd = useCallback( @@ -209,9 +197,10 @@ const MyCards: React.FC = () => { {...provided.dragHandleProps}> + onClick={event => handleSelectCard( card, + event, ) } src={`/cards/thumbnails/${card.name}.png`} @@ -263,9 +252,10 @@ const MyCards: React.FC = () => { {...provided.dragHandleProps}> + onClick={event => handleSelectCard( card, + event, ) } src={`/cards/thumbnails/${card.name}.png`}