From 83e2685c6acc6352523f93a7ca830ba8a6172a03 Mon Sep 17 00:00:00 2001 From: Mattias Tall Date: Tue, 26 May 2026 17:41:06 +0200 Subject: [PATCH] Quality selector auto-triggers re-download on change when video is saved MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changing the quality dropdown while a video is already downloaded now immediately deletes the old file and starts a fresh download at the new quality — no separate Re-download button needed. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/pages/Watch.jsx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/frontend/src/pages/Watch.jsx b/frontend/src/pages/Watch.jsx index 300ba07..66e91e9 100644 --- a/frontend/src/pages/Watch.jsx +++ b/frontend/src/pages/Watch.jsx @@ -710,7 +710,7 @@ export default function Watch() { }, [playRequested, fileReady, dlStatus?.status, dlStatus?.file_url, video?.is_downloaded, youtubeVideoId, pollForFile]); // eslint-disable-line react-hooks/exhaustive-deps const downloadMut = useMutation({ - mutationFn: () => createDownload(youtubeVideoId, selectedQuality), + mutationFn: (quality) => createDownload(youtubeVideoId, quality ?? selectedQuality), onSuccess: (res) => { setDownloadId(res.data.id); refetchVideo(); @@ -722,7 +722,7 @@ export default function Watch() { setPlayRequested(true); downloadMut.mutate(); }, [downloadMut]); - const handleRedownload = useCallback(async () => { + const handleRedownload = useCallback(async (quality) => { const dlId = downloadId ?? allDownloads.find( d => d.youtube_video_id === youtubeVideoId && d.status === "complete" )?.id; @@ -736,7 +736,7 @@ export default function Watch() { setIsRedownloading(false); qc.invalidateQueries({ queryKey: ["downloads"] }); refetchVideo(); - downloadMut.mutate(); + downloadMut.mutate(quality); }, [downloadId, allDownloads, youtubeVideoId, downloadMut, refetchVideo, qc]); const saveProgress = useCallback((secs) => { @@ -933,7 +933,11 @@ export default function Watch() { {!isDownloading && !downloadMut.isPending && !isRedownloading && (