From a5882e1eff1331dccd014164744e0a26a7e4a0a9 Mon Sep 17 00:00:00 2001 From: Vilerio <69359417+Vilerio@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:23:02 +0200 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20saut=20d'un=20cours=20annul=C3=A9=20?= =?UTF-8?q?pour=20le=20widget=20prochain=20cours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widgets/Components/NextCourse.tsx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/widgets/Components/NextCourse.tsx b/src/widgets/Components/NextCourse.tsx index cbc31b5c..b30da7de 100644 --- a/src/widgets/Components/NextCourse.tsx +++ b/src/widgets/Components/NextCourse.tsx @@ -35,33 +35,33 @@ const NextCourseWidget = forwardRef(({ hidden, setHidden, loading, setLoading }: setLoading(true); setNextCourse(null); setHidden(true); - + if (!account.instance || !timetables) { return; } - + const allCourses = Object.values(timetables).flat(); - + let nextCourse = null; - + nextCourse = allCourses - .filter(c => c.startTimestamp < today && c.endTimestamp > today) + .filter(c => c.startTimestamp < today && c.endTimestamp > today && c.status !== "Cours annulé") .sort((a, b) => b.endTimestamp - a.endTimestamp)[0]; - + if (!nextCourse) { nextCourse = allCourses - .filter(c => c.startTimestamp > today) + .filter(c => c.startTimestamp > today && c.status !== "Cours annulé") .sort((a, b) => a.startTimestamp - b.startTimestamp)[0]; } - + if (nextCourse) { setNextCourse(nextCourse); setHidden(false); } - + setLoading(false); }(); - }, [account.instance, timetables]); + }, [account.instance, timetables]); return !hidden && ( Date: Thu, 5 Sep 2024 10:24:26 +0200 Subject: [PATCH 2/2] chore: remove useless indentation --- src/widgets/Components/NextCourse.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/widgets/Components/NextCourse.tsx b/src/widgets/Components/NextCourse.tsx index b30da7de..c46c5f74 100644 --- a/src/widgets/Components/NextCourse.tsx +++ b/src/widgets/Components/NextCourse.tsx @@ -35,30 +35,30 @@ const NextCourseWidget = forwardRef(({ hidden, setHidden, loading, setLoading }: setLoading(true); setNextCourse(null); setHidden(true); - + if (!account.instance || !timetables) { return; } - + const allCourses = Object.values(timetables).flat(); - + let nextCourse = null; - + nextCourse = allCourses .filter(c => c.startTimestamp < today && c.endTimestamp > today && c.status !== "Cours annulé") .sort((a, b) => b.endTimestamp - a.endTimestamp)[0]; - + if (!nextCourse) { nextCourse = allCourses .filter(c => c.startTimestamp > today && c.status !== "Cours annulé") .sort((a, b) => a.startTimestamp - b.startTimestamp)[0]; } - + if (nextCourse) { setNextCourse(nextCourse); setHidden(false); } - + setLoading(false); }(); }, [account.instance, timetables]);