diff --git a/frontend/src/pages/Watch.jsx b/frontend/src/pages/Watch.jsx index 072bf09..300ba07 100644 --- a/frontend/src/pages/Watch.jsx +++ b/frontend/src/pages/Watch.jsx @@ -562,6 +562,7 @@ export default function Watch() { const [queued, setQueued] = useState(null); const [liked, setLiked] = useState(null); const [disliked, setDisliked] = useState(null); + const [isRedownloading, setIsRedownloading] = useState(false); const [selectedQuality, setSelectedQuality] = useState(null); const [speed, setSpeed] = useState(1); const [autoplay, setAutoplay] = useState(false); @@ -721,6 +722,22 @@ export default function Watch() { setPlayRequested(true); downloadMut.mutate(); }, [downloadMut]); + const handleRedownload = useCallback(async () => { + const dlId = downloadId ?? allDownloads.find( + d => d.youtube_video_id === youtubeVideoId && d.status === "complete" + )?.id; + if (!dlId) return; + setIsRedownloading(true); + try { await deleteDownload(dlId); } catch (_) {} + setFileReady(false); + setConfirmedFileUrl(null); + setDownloadId(null); + setPlayRequested(false); + setIsRedownloading(false); + qc.invalidateQueries({ queryKey: ["downloads"] }); + refetchVideo(); + downloadMut.mutate(); + }, [downloadId, allDownloads, youtubeVideoId, downloadMut, refetchVideo, qc]); const saveProgress = useCallback((secs) => { if (!video?.id) return; @@ -792,6 +809,7 @@ export default function Watch() { const isLiked = liked ?? video?.liked ?? false; const isDisliked = disliked ?? (video?.rating === -1) ?? false; const dlComplete = dlStatus?.status === "complete" || video?.is_downloaded; + const downloadedResolution = dlStatus?.resolution ?? video?.download_resolution; const isFollowed = followMut.isSuccess || video?.channel_followed; const subs = formatSubs(channel?.subscriber_count); @@ -912,7 +930,7 @@ export default function Watch() { {/* Actions */}