diff --git a/src/client/actions/airdcpp.actions.tsx b/src/client/actions/airdcpp.actions.tsx index bf1cb3f..0fe54a4 100644 --- a/src/client/actions/airdcpp.actions.tsx +++ b/src/client/actions/airdcpp.actions.tsx @@ -17,6 +17,7 @@ import { LS_SINGLE_IMPORT, IMS_COMIC_BOOK_DB_OBJECT_FETCHED, AIRDCPP_TRANSFERS_FETCHED, + LIBRARY_ISSUE_BUNDLES, } from "../constants/action-types"; import { isNil } from "lodash"; import axios from "axios"; @@ -233,11 +234,15 @@ export const getTransfers = }); const bundleIds = bundles.map((bundle) => bundle.id); // get issues with matching bundleIds - const issues = await axios({ + const issue_bundles = await axios({ url: `${SEARCH_SERVICE_BASE_URI}/groupIssuesByBundles`, method: "POST", data: { bundleIds }, }); + dispatch({ + type: LIBRARY_ISSUE_BUNDLES, + issue_bundles, + }); } } catch (err) { diff --git a/src/client/components/ComicDetail/DownloadsPanel.tsx b/src/client/components/ComicDetail/DownloadsPanel.tsx index 69e740a..8d4047b 100644 --- a/src/client/components/ComicDetail/DownloadsPanel.tsx +++ b/src/client/components/ComicDetail/DownloadsPanel.tsx @@ -1,6 +1,5 @@ import React, { useEffect, useContext, ReactElement } from "react"; import { - getDownloadProgress, getBundlesForComic, } from "../../actions/airdcpp.actions"; import { useDispatch, useSelector } from "react-redux"; diff --git a/src/client/components/Downloads/Downloads.tsx b/src/client/components/Downloads/Downloads.tsx index f2d986d..8f3869d 100644 --- a/src/client/components/Downloads/Downloads.tsx +++ b/src/client/components/Downloads/Downloads.tsx @@ -1,9 +1,11 @@ -import React, { ReactElement, useCallback, useContext, useEffect } from "react"; +import React, { ReactElement, useCallback, useContext, useEffect, useState } from "react"; import { getTransfers } from "../../actions/airdcpp.actions"; import { useDispatch, useSelector } from "react-redux"; import { AirDCPPSocketContext } from "../../context/AirDCPPSocket"; -import { isEmpty, isUndefined } from "lodash"; +import { isEmpty, isNil, isUndefined } from "lodash"; import { searchIssue } from "../../actions/fileops.actions"; +import { determineCoverFile } from "../../shared/utils/metadata.utils"; +import MetadataPanel from "../shared/MetadataPanel"; interface IDownloadsProps { data: any; @@ -19,22 +21,8 @@ export const Downloads = (props: IDownloadsProps): ReactElement => { const airDCPPTransfers = useSelector( (state: RootState) => state.airdcpp.transfers, ); - useEffect(() => { - dispatch( - searchIssue( - { - query: {}, - }, - { - pagination: { - size: 25, - from: 0, - }, - type: "wanted", - }, - ), - ); - }, []); + const issueBundles = useSelector((state: RootState) => state.airdcpp.issue_bundles); + const [bundles, setBundles] = useState([]); // Make the call to get all transfers from AirDC++ useEffect(() => { if (!isUndefined(socket) && !isEmpty(settings)) { @@ -47,9 +35,47 @@ export const Downloads = (props: IDownloadsProps): ReactElement => { } }, [socket]); - - // const getAllDownloads = useCallback(() => {}); - return
{JSON.stringify(airDCPPTransfers, null, 2)};
+ useEffect(() => {
+ if (!isUndefined(issueBundles)) {
+ const foo = issueBundles.data.map((bundle) => {
+ const { rawFileDetails, inferredMetadata, acquisition: { directconnect: { downloads } }, sourcedMetadata: { locg, comicvine } } = bundle;
+ const { issueName, url } = determineCoverFile({
+ rawFileDetails, comicvine, locg,
+ });
+ return { ...bundle, issueName, url }
+
+ })
+ setBundles(foo);
+ }
+
+ }, [issueBundles])
+
+ return !isNil(bundles) ?
+ {JSON.stringify(bundle.acquisition.directconnect.downloads, null, 2)}
+ >
+ })}
+