Forgot to save TextComponent, and cleanup some warnings

This commit is contained in:
Carlos Mesquita
2024-08-20 20:02:59 +01:00
parent 30da295c60
commit 2e699d7e25
3 changed files with 9 additions and 2 deletions

View File

@@ -99,14 +99,17 @@ const TextComponent: React.FC<Props> = ({part, contextWord, setContextWordLine})
}); });
if (textRef.current) { if (textRef.current) {
// eslint-disable-next-line react-hooks/exhaustive-deps
resizeObserver.observe(textRef.current); resizeObserver.observe(textRef.current);
} }
return () => { return () => {
if (textRef.current) { if (textRef.current) {
// eslint-disable-next-line react-hooks/exhaustive-deps
resizeObserver.unobserve(textRef.current); resizeObserver.unobserve(textRef.current);
} }
}; };
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [part.context, contextWord]); }, [part.context, contextWord]);
/*if (typeof part.showContextLines === "undefined") { /*if (typeof part.showContextLines === "undefined") {

View File

@@ -53,7 +53,7 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
if (showSolutions && exerciseIndex && userSolutions[exerciseIndex].shuffleMaps) { if (showSolutions && exerciseIndex && userSolutions[exerciseIndex].shuffleMaps) {
setShuffleMaps(userSolutions[exerciseIndex].shuffleMaps as ShuffleMap[]) setShuffleMaps(userSolutions[exerciseIndex].shuffleMaps as ShuffleMap[])
} }
}, [showSolutions]) }, [showSolutions, exerciseIndex, setShuffleMaps, userSolutions])
useEffect(() => { useEffect(() => {
if (hasExamEnded && exerciseIndex === -1) { if (hasExamEnded && exerciseIndex === -1) {
@@ -99,6 +99,7 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
setShuffleMaps(newShuffleMaps); setShuffleMaps(newShuffleMaps);
} else { } else {
console.log("retrieving shuffles");
exercise.questions = exercise.questions.map(question => { exercise.questions = exercise.questions.map(question => {
const questionShuffleMap = shuffleMaps.find(map => map.id === question.id); const questionShuffleMap = shuffleMaps.find(map => map.id === question.id);
if (questionShuffleMap) { if (questionShuffleMap) {
@@ -148,6 +149,7 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
if (exerciseIndex !== -1) { if (exerciseIndex !== -1) {
setCurrentExercise(getExercise()); setCurrentExercise(getExercise());
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [partIndex, exerciseIndex, shuffleMaps, exam.parts[partIndex].context]); }, [partIndex, exerciseIndex, shuffleMaps, exam.parts[partIndex].context]);
@@ -173,6 +175,7 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
setContextWord(undefined); setContextWord(undefined);
} }
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentExercise, storeQuestionIndex]); }, [currentExercise, storeQuestionIndex]);
const nextExercise = (solution?: UserSolution) => { const nextExercise = (solution?: UserSolution) => {
@@ -269,6 +272,7 @@ export default function Level({ exam, showSolutions = false, onFinish, editing =
if (exerciseIndex === -1) { if (exerciseIndex === -1) {
nextExercise() nextExercise()
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [exerciseIndex]) }, [exerciseIndex])
const calculateExerciseIndex = () => { const calculateExerciseIndex = () => {

View File

@@ -287,7 +287,7 @@ export default function ExamPage({page}: Props) {
if(exam && exam.module === "level" && exam.parts[0].intro && !showSolutions) { if(exam && exam.module === "level" && exam.parts[0].intro && !showSolutions) {
setBgColor("bg-ielts-level-light"); setBgColor("bg-ielts-level-light");
} }
}, [exam]) }, [exam, showSolutions, setBgColor])
const checkIfStatsHaveBeenEvaluated = (ids: string[]) => { const checkIfStatsHaveBeenEvaluated = (ids: string[]) => {
setTimeout(async () => { setTimeout(async () => {