Skip to content
Snippets Groups Projects
Commit 3c093f48 authored by Simon Künzel's avatar Simon Künzel
Browse files

Fix video suggestion lecture order, Closes #81

parent b5af65d1
No related branches found
No related tags found
No related merge requests found
Pipeline #6914 passed
...@@ -609,10 +609,14 @@ function Chapters({ chapters, seekTo }: { chapters?: chapter[]; seekTo: (time: n ...@@ -609,10 +609,14 @@ function Chapters({ chapters, seekTo }: { chapters?: chapter[]; seekTo: (time: n
function VideoSuggestions({ course, lecture }: { course: course; lecture: lecture }) { function VideoSuggestions({ course, lecture }: { course: course; lecture: lecture }) {
const { language } = useLanguage(); const { language } = useLanguage();
// find previous and next lecture // find previous and next lecture
const prevLecture = course.lectures?.findLast( const sortedLectures = course.lectures?.sort((a, b) => {
// time looks like this: 2015-10-20T12:15:00
return new Date(a.time).valueOf() - new Date(b.time).valueOf();
});
const prevLecture = sortedLectures?.findLast(
(l) => new Date(l.time) < new Date(lecture.time) && (l.media_sources ?? []).length > 0, (l) => new Date(l.time) < new Date(lecture.time) && (l.media_sources ?? []).length > 0,
); );
const nextLecture = course.lectures?.find( const nextLecture = sortedLectures?.find(
(l) => new Date(l.time) > new Date(lecture.time) && (l.media_sources ?? []).length > 0, (l) => new Date(l.time) > new Date(lecture.time) && (l.media_sources ?? []).length > 0,
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment