diff --git a/capacitor.config.ts b/capacitor.config.ts index b91fad1..2617f01 100644 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -8,12 +8,7 @@ const config: CapacitorConfig = { androidScheme: "https", }, android: { - buildOptions: { - keystorePath: - "/Users/willkelly/Documents/Work/Code_support_files/DotMobile/DotMobileKs", - keystoreAlias: "key0", - signingType: "apksigner", - }, + buildOptions: {}, }, }; diff --git a/src/components/Settings/BulkListing.tsx b/src/components/Settings/BulkListing.tsx index d874d3f..133eddf 100644 --- a/src/components/Settings/BulkListing.tsx +++ b/src/components/Settings/BulkListing.tsx @@ -56,6 +56,7 @@ export function BulkListing({ const [booksToCancel, setBooksToCancel] = useState>( [], ); + function allBooks() { const allVals = Object.values(playlistData.formattedVideos).map((value) => { return { @@ -102,7 +103,7 @@ export function BulkListing({ } } } - function cancelButonText() { + function cancelButtonText() { if (window.dotAppStopAllDownloads) { return t("cancelling"); } @@ -161,13 +162,17 @@ export function BulkListing({ vidName: currentVid.name || currentVid.reference_id || "unknown video", vidId: currentVid.id || "", }); + // reset selection when action is finished + setBooksSelected(undefined); + setBookNamesSelected([]); }, 1000); window.dotAppBooksToCancel = []; window.dotAppStopAllDownloads = false; } - async function deleteSelectedBooks() { - if (!booksSelected) return; - for await (const book of booksSelected) { + async function deleteSelectedBooks(books?: IVidWithCustom[][]) { + const booksToUse = books ? books : booksSelected; + if (!booksToUse) return; + for await (const book of booksToUse) { for await (const vidChapter of book) { const vidSaver = makeVidSaver(playlistSlug, vidChapter); const currentPlaylistData = @@ -184,14 +189,19 @@ export function BulkListing({ setShapedPlaylist: setShapedPlaylist, setCurrentVid: setCurrentVid, }); + // reset selection when action is finished + setBooksSelected(undefined); + setBookNamesSelected([]); } - function addAllVidsFromBook(videos: IVidWithCustom[]) { + function clearBookFromFs(videos: IVidWithCustom[]) { setBooksSelected((prev) => { if (prev) { const newState = [...prev, videos]; return newState; } + // A side cb + deleteSelectedBooks([videos]); return [videos]; }); } @@ -222,7 +232,7 @@ export function BulkListing({ "--padding-top": ".625rem", }} > - {cancelButonText()} + {cancelButtonText()} diff --git a/src/components/Settings/DownloadBookItem.tsx b/src/components/Settings/DownloadBookItem.tsx index 93781a9..8a2d2fa 100644 --- a/src/components/Settings/DownloadBookItem.tsx +++ b/src/components/Settings/DownloadBookItem.tsx @@ -21,9 +21,11 @@ type BookToDownloadProps = { bookNamesSelected: string[]; booksToCancel: (string | undefined)[]; setBooksToCancel: Dispatch>; - addAllVidsFromBook(videos: IVidWithCustom[]): void; - deleteSelectedBooks(): Promise; + clearBookFromFs(videos: IVidWithCustom[]): void; }; +function bookIsFullyDownloaded(book: IVidWithCustom[]) { + return book.every((vid) => !!vid.savedSources?.video); +} export function BookToDownload(props: BookToDownloadProps) { const { t } = useTranslation(); const { book } = props; @@ -65,6 +67,9 @@ export function BookToDownload(props: BookToDownloadProps) { function getCurrentProgress() { return props.downloadProgress?.amount || 0; } + function isChecked() { + return props.bookNamesSelected.includes(bookName || ""); + } return (
  • { props.handleChecked(e, book.value, bookName || ""); }} + checked={isChecked()} labelPlacement="end" + disabled={bookIsFullyDownloaded(book.value)} > {book.bookName}{" "} @@ -98,8 +105,7 @@ export function BookToDownload(props: BookToDownloadProps) { color="primary" className="text-surface" onClick={() => { - props.addAllVidsFromBook(book.value); - props.deleteSelectedBooks(); + props.clearBookFromFs(book.value); }} style={{ "--border-width": "1px",