From 45da47f99b60bac870798b77ecd9a5ec6e0f5214 Mon Sep 17 00:00:00 2001 From: MerlinScheurer Date: Fri, 31 Jan 2025 17:56:35 +0100 Subject: [PATCH] Fix sponsorblock set progress onVideoEnd --- frontend/src/components/VideoPlayer.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/VideoPlayer.tsx b/frontend/src/components/VideoPlayer.tsx index 63edf527..339d2706 100644 --- a/frontend/src/components/VideoPlayer.tsx +++ b/frontend/src/components/VideoPlayer.tsx @@ -158,10 +158,16 @@ const VideoPlayer = ({ watched: boolean, setSponsorSegmentSkipped?: Dispatch>, ) => - async () => { - if (!watched) { - // Check if video is already marked as watched - await updateWatchedState({ id: youtubeId, is_watched: true }); + async (videoTag: VideoTag) => { + const currentTime = Number(videoTag.currentTarget.currentTime); + + const videoProgressResponse = await updateVideoProgressById({ + youtubeId, + currentProgress: currentTime, + }); + + if (videoProgressResponse.watched && watched !== videoProgressResponse.watched) { + onWatchStateChanged?.(true); } setSponsorSegmentSkipped?.((segments: SponsorSegmentsSkippedType) => {