From 4c23011d0efb352eb1ca293b932e071fdec6c2b0 Mon Sep 17 00:00:00 2001 From: sooyeoniya Date: Fri, 23 Aug 2024 16:07:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=EC=B9=B4=EB=93=9C=20=EC=98=B5?= =?UTF-8?q?=EC=85=98=20=EC=84=A0=ED=83=9D=20=EC=8B=9C=20409=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=98=A4=EB=A5=98=20throttle=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RushGameComponents/RushCardComparison.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/client/src/features/RushGame/RushGameComponents/RushCardComparison.tsx b/client/src/features/RushGame/RushGameComponents/RushCardComparison.tsx index 75eb6a85..c3e08734 100644 --- a/client/src/features/RushGame/RushGameComponents/RushCardComparison.tsx +++ b/client/src/features/RushGame/RushGameComponents/RushCardComparison.tsx @@ -1,4 +1,4 @@ -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { useCookies } from "react-cookie"; import { RushAPI } from "@/apis/rushAPI.ts"; import { CARD_OPTION } from "@/constants/Rush/rushCard.ts"; @@ -16,18 +16,29 @@ export default function RushCardComparison() { const gameState = useRushGameStateContext(); const dispatch = useRushGameDispatchContext(); const { getRushUserParticipationStatus } = useFetchRushUserParticipationStatus(); + const [throttle, setThrottle] = useState(false); const { data: postSelectedRushOptionResponse, isSuccess: isSuccessPostSelectedRushOption, + isLoading: isLoadingPostSelectedRushOption, fetchData: postSelectedRushOptionApply, } = useFetch( ({ token, optionId }) => RushAPI.postSelectedRushOptionApply(token, optionId) ); const handleCardSelection = async (optionId: CardOption) => { - await postSelectedRushOptionApply({ token: cookies[COOKIE_KEY.ACCESS_TOKEN], optionId }); - dispatch({ type: RUSH_ACTION.SET_USER_OPTION, payload: optionId }); + if (!throttle && !isLoadingPostSelectedRushOption) { + await postSelectedRushOptionApply({ + token: cookies[COOKIE_KEY.ACCESS_TOKEN], + optionId, + }); + dispatch({ type: RUSH_ACTION.SET_USER_OPTION, payload: optionId }); + setThrottle(true); + setTimeout(() => { + setThrottle(false); + }, 1000); + } }; useEffect(() => { From 282961d79fecc0c47b977e8ed7a5b1996514f0ef Mon Sep 17 00:00:00 2001 From: sooyeoniya Date: Fri, 23 Aug 2024 16:20:20 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20POST=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=8B=9C=20=EC=97=90=EB=9F=AC=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RushGame/RushGameComponents/RushCardComparison.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/features/RushGame/RushGameComponents/RushCardComparison.tsx b/client/src/features/RushGame/RushGameComponents/RushCardComparison.tsx index c3e08734..8a0e97f1 100644 --- a/client/src/features/RushGame/RushGameComponents/RushCardComparison.tsx +++ b/client/src/features/RushGame/RushGameComponents/RushCardComparison.tsx @@ -24,7 +24,8 @@ export default function RushCardComparison() { isLoading: isLoadingPostSelectedRushOption, fetchData: postSelectedRushOptionApply, } = useFetch( - ({ token, optionId }) => RushAPI.postSelectedRushOptionApply(token, optionId) + ({ token, optionId }) => RushAPI.postSelectedRushOptionApply(token, optionId), + false ); const handleCardSelection = async (optionId: CardOption) => {