From 2a919ae0820b7990fb2de02e7475eb3f33345e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Tainon?= Date: Mon, 31 Jul 2023 11:31:58 +0200 Subject: [PATCH] [Fix] Don't display next arrow if hint is unavailable --- frontend/task/hints/TaskHints.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/task/hints/TaskHints.tsx b/frontend/task/hints/TaskHints.tsx index 06a99d42..3bbd13ee 100644 --- a/frontend/task/hints/TaskHints.tsx +++ b/frontend/task/hints/TaskHints.tsx @@ -20,7 +20,7 @@ export function TaskHints(props: TaskHintProps) { const displayedHintIndex = null === displayedHintId ? unlockedHintIds.length : unlockedHintIds.indexOf(displayedHintId); const displayedHint = availableHints.find(hint => displayedHintId === hint.id); const nextAvailableHint = availableHints.find(hint => -1 === unlockedHintIds.indexOf(hint.id)); - const canAskMoreHints = undefined !== nextAvailableHint && !displayedHint?.question && !displayedHint?.disableNext; + let canAskMoreHints = undefined !== nextAvailableHint && !displayedHint?.question && !displayedHint?.disableNext; const dispatch = useDispatch(); @@ -42,7 +42,11 @@ export function TaskHints(props: TaskHintProps) { if (displayedHint) { if (!displayedHint.disableNext && !displayedHint.question) { if (displayedHint.nextHintId) { - currentHintNextId = displayedHint.nextHintId; + if (availableHints.find(hint => displayedHint.nextHintId === hint.id)) { + currentHintNextId = displayedHint.nextHintId; + } else { + canAskMoreHints = false; + } } }