From 96b55bf9d57ae808da1c5ff5b6455687e912bd74 Mon Sep 17 00:00:00 2001 From: MerlinScheurer Date: Fri, 28 Mar 2025 11:50:53 +0100 Subject: [PATCH] Fix download page requesting pending downloads twice --- frontend/src/pages/Download.tsx | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/frontend/src/pages/Download.tsx b/frontend/src/pages/Download.tsx index c7bc19cf..f9b6ed52 100644 --- a/frontend/src/pages/Download.tsx +++ b/frontend/src/pages/Download.tsx @@ -98,24 +98,26 @@ const Download = () => { useEffect(() => { (async () => { - const videosResponse = await loadDownloadQueue( - currentPage, - channelFilterFromUrl, - showIgnored, - ); - const { data: channelResponseData } = videosResponse ?? {}; - const videoCount = channelResponseData?.paginate?.total_hits; + if (refresh) { + const videosResponse = await loadDownloadQueue( + currentPage, + channelFilterFromUrl, + showIgnored, + ); + const { data: channelResponseData } = videosResponse ?? {}; + const videoCount = channelResponseData?.paginate?.total_hits; - if (videoCount && lastVideoCount !== videoCount) { - setLastVideoCount(videoCount); + if (videoCount && lastVideoCount !== videoCount) { + setLastVideoCount(videoCount); + } + + setDownloadResponse(videosResponse); + setRefresh(false); } - - setDownloadResponse(videosResponse); - setRefresh(false); })(); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [refresh, showIgnored, currentPage, downloadPending]); + }, [refresh, showIgnored, currentPage]); useEffect(() => { (async () => {