From 491d36498012fd466e07254b8b85c83e3cf1fbf2 Mon Sep 17 00:00:00 2001 From: Dorian Koch <doriank@fsmpi.rwth-aachen.de> Date: Sat, 12 Oct 2024 22:39:59 +0200 Subject: [PATCH] Fix "Next lecture" shown in player even when the next lecture has no media sources, closes #77 --- src/components/Player.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Player.tsx b/src/components/Player.tsx index e590900..a6cf6b3 100644 --- a/src/components/Player.tsx +++ b/src/components/Player.tsx @@ -609,8 +609,12 @@ function Chapters({ chapters, seekTo }: { chapters?: chapter[]; seekTo: (time: n function VideoSuggestions({ course, lecture }: { course: course; lecture: lecture }) { const { language } = useLanguage(); // find previous and next lecture - const prevLecture = course.lectures?.findLast((l) => new Date(l.time) < new Date(lecture.time)); - const nextLecture = course.lectures?.find((l) => new Date(l.time) > new Date(lecture.time)); + const prevLecture = course.lectures?.findLast( + (l) => new Date(l.time) < new Date(lecture.time) && (l.media_sources ?? []).length > 0, + ); + const nextLecture = course.lectures?.find( + (l) => new Date(l.time) > new Date(lecture.time) && (l.media_sources ?? []).length > 0, + ); return ( <div className="d-flex w-100 flex-column flex-sm-row"> -- GitLab