From c09594cb2384fc4fd97ec26af502dc12ecb54262 Mon Sep 17 00:00:00 2001 From: Will Kelly Date: Thu, 10 Oct 2024 11:59:25 -0500 Subject: [PATCH] fix one more ui bug around downloading --- src/components/Settings.tsx | 9 ++++----- src/components/Settings/BulkListing.tsx | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index 70b5cb4..6b11933 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -114,13 +114,10 @@ export function Settings(props: ISettings) { } } function breakLoop() { - if (window.dotAppStopAllDownloads) { + if (window.dotAppStopAllDownloads || bookDownloadRequestIsAborted()) { props.setIsSavingSingle([]); return true; } - if (bookDownloadRequestIsAborted()) { - return true; - } return false; } @@ -146,7 +143,6 @@ export function Settings(props: ISettings) { fetchNum += 1; } } - const result = await vidSaver.aggregateWipBlobsIntoOneAndWriteFs(allExpectedChunks); // todo maybe?: some error handling here? Returning here is fine right now, the jobs that called it just assumes the download completed, the state is read from fs as source of truth (so no falsy UI since we don't actually combine the final blob). This right now just means that some fetch went wrong (don't know why), but if the job is started again from here, well, no big problem. @@ -195,6 +191,9 @@ export function Settings(props: ISettings) { vidName: vid.name || "", vidId: vid.id || "", }); + window.dotAppBooksToCancel = []; + window.dotAppStopAllDownloads = false; + props.setIsSavingSingle((prev) => prev.filter((id) => id !== vid.id)); }, 1000); } async function handleSingleVidDelete(vid: IVidWithCustom) { diff --git a/src/components/Settings/BulkListing.tsx b/src/components/Settings/BulkListing.tsx index 6d9709c..d64d376 100644 --- a/src/components/Settings/BulkListing.tsx +++ b/src/components/Settings/BulkListing.tsx @@ -160,7 +160,6 @@ export function BulkListing({ await saveVidOffline(vidChapter, currentPlaylistData); } } - setTimeout(() => { setDownloadProgress({ amount: 0, @@ -169,12 +168,13 @@ export function BulkListing({ vidId: currentVid.id || "", }); // reset selection when action is finished + window.dotAppBooksToCancel = []; + window.dotAppStopAllDownloads = false; setBooksSelected(undefined); setBookNamesSelected([]); }, 1000); - window.dotAppBooksToCancel = []; - window.dotAppStopAllDownloads = false; } + async function deleteSelectedBooks(books?: IVidWithCustom[][]) { const booksToUse = books ? books : booksSelected; if (!booksToUse) return;