From 8d409b6f7f7611d7ec71e2aaeca664d1d8916db8 Mon Sep 17 00:00:00 2001 From: rngsurrounded Date: Mon, 3 Mar 2025 21:23:50 +0900 Subject: [PATCH] history fix --- .../CompetitionSession/modules/TaskSolution/index.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx b/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx index 1bf87d1..5267dbb 100644 --- a/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx +++ b/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx @@ -71,12 +71,11 @@ const TaskSolution: React.FC = ({ }, [task.id, solutionHistory]); useEffect(() => { - if (solutionHistory.length > 0 && displayedSolution) { - const latestSolution = solutionHistory[solutionHistory.length - 1]; - - if (latestSolution.id !== displayedSolution.id) { - setDisplayedSolution(latestSolution); - } + if (solutionHistory.length > 0 && + (!displayedSolution || + (solutionHistory[solutionHistory.length - 1].id !== displayedSolution.id && + displayedSolution.id === solutionHistory[solutionHistory.length - 2]?.id))) { + setDisplayedSolution(solutionHistory[solutionHistory.length - 1]); } }, [solutionHistory, displayedSolution]);