From bc6d39b004f4a24641142206a21cecabb1214f32 Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Mon, 9 Dec 2024 23:38:40 +0530 Subject: [PATCH] refactor: cleanup video player --- src/routes/_api/player/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/_api/player/index.tsx b/src/routes/_api/player/index.tsx index badb995..e6bf48a 100644 --- a/src/routes/_api/player/index.tsx +++ b/src/routes/_api/player/index.tsx @@ -653,7 +653,7 @@ function VideoPlayer() { }; const handlePrevChapter = useCallback(() => { - const chapters = item?.Chapters?.filter((chapter, index) => { + const chapters = item?.Chapters?.filter((chapter) => { if ((chapter.StartPositionTicks ?? 0) <= progress) { return true; } @@ -663,7 +663,7 @@ function VideoPlayer() { } if (chapters?.length === 1) { player.current?.seekTo(ticksToSec(chapters[0].StartPositionTicks ?? 0)); - } else if (chapters?.length > 1) { + } else if ((chapters?.length ?? 0) > 1) { player.current?.seekTo( ticksToSec(chapters?.[chapters.length - 2].StartPositionTicks ?? 0), ); @@ -673,7 +673,7 @@ function VideoPlayer() { // player.current?.seekTo(ticksToSec(currentChapter?.[0]?.StartPositionTicks ?? 0)); }, [progress, playsessionId]); const handleNextChapter = useCallback(() => { - const next = item?.Chapters?.filter((chapter, index) => { + const next = item?.Chapters?.filter((chapter) => { if ((chapter.StartPositionTicks ?? 0) > progress) { return true; }