From 5cad051e7dd4950677b0d9c04dec3c6208cb2053 Mon Sep 17 00:00:00 2001 From: rngsurrounded Date: Mon, 3 Mar 2025 07:06:50 +0900 Subject: [PATCH] test --- .../modules/TaskSolution/index.tsx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx b/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx index 697b955..3daea18 100644 --- a/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx +++ b/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx @@ -41,22 +41,17 @@ const TaskSolution: React.FC = ({ }); const solutionHistory = solutionsQuery.data || []; - - const getLatestSolution = () => { - return solutionHistory.length > 0 ? solutionHistory[solutionHistory.length - 1] : null; - }; useEffect(() => { if (solutionHistory.length > 0 && !currentSolution) { - setCurrentSolution(getLatestSolution()); + setCurrentSolution(solutionHistory[0]); } }, [solutionHistory, currentSolution]); useEffect(() => { - const latestSolution = getLatestSolution(); - if (solutionHistory.length > 0 && currentSolution && latestSolution && - latestSolution.id !== currentSolution.id) { - setCurrentSolution(latestSolution); + if (solutionHistory.length > 0 && currentSolution && + solutionHistory[0].id !== currentSolution.id) { + setCurrentSolution(solutionHistory[0]); } }, [solutionHistory, currentSolution]); @@ -95,7 +90,7 @@ const TaskSolution: React.FC = ({ const handleSolutionSelect = (solution: Solution) => { setCurrentSolution(solution); - setIsHistoryOpen(false); + setIsHistoryOpen(false); }; const handleClearExistingFile = () => {