From 365fa2e115330777f902dad21606d6b2dbf7c3c2 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Sun, 24 Jul 2022 22:20:25 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8E=20Integration=20with=20DC++=20down?= =?UTF-8?q?loads=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/actions/airdcpp.actions.tsx | 31 +++++++++---------- .../ComicDetail/AcquisitionPanel.tsx | 2 +- .../components/ComicDetail/DownloadsPanel.tsx | 4 +++ .../components/ComicDetail/TabControls.tsx | 7 ++--- src/client/components/Dashboard/PullList.tsx | 2 +- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/client/actions/airdcpp.actions.tsx b/src/client/actions/airdcpp.actions.tsx index fe6e16a..bf1cb3f 100644 --- a/src/client/actions/airdcpp.actions.tsx +++ b/src/client/actions/airdcpp.actions.tsx @@ -4,7 +4,7 @@ import { PriorityEnum, SearchResponse, } from "threetwo-ui-typings"; -import { LIBRARY_SERVICE_BASE_URI } from "../constants/endpoints"; +import { LIBRARY_SERVICE_BASE_URI, SEARCH_SERVICE_BASE_URI } from "../constants/endpoints"; import { AIRDCPP_SEARCH_RESULTS_ADDED, AIRDCPP_SEARCH_RESULTS_UPDATED, @@ -130,7 +130,6 @@ export const downloadAirDCPPItem = true, ); } - console.log(comicObject); let bundleDBImportResult = {}; const downloadResult = await ADCPPSocket.post( `search/${instanceId}/results/${resultId}/download`, @@ -200,15 +199,17 @@ export const getBundlesForComic = }, }); // get only the bundles applicable for the comic - const filteredBundles = comicObject.data.acquisition.directconnect.map( - async ({ bundleId }) => { - return await ADCPPSocket.get(`queue/bundles/${bundleId}`); - }, - ); - dispatch({ - type: AIRDCPP_BUNDLES_FETCHED, - bundles: await Promise.all(filteredBundles), - }); + if (comicObject.data.acquisition.directconnect) { + const filteredBundles = comicObject.data.acquisition.directconnect.downloads.map( + async ({ bundleId }) => { + return await ADCPPSocket.get(`queue/bundles/${bundleId}`); + }, + ); + dispatch({ + type: AIRDCPP_BUNDLES_FETCHED, + bundles: await Promise.all(filteredBundles), + }); + } } catch (error) { throw error; } @@ -224,20 +225,18 @@ export const getTransfers = true, ); } - const bundles = await ADCPPSocket.get("queue/bundles/1/50", {}); + const bundles = await ADCPPSocket.get("queue/bundles/1/85", {}); if (!isNil(bundles)) { - dispatch({ type: AIRDCPP_TRANSFERS_FETCHED, bundles, }); const bundleIds = bundles.map((bundle) => bundle.id); - console.log(bundleIds); // get issues with matching bundleIds const issues = await axios({ - url: `${LIBRARY_SERVICE_BASE_URI}/groupIssuesByBundles`, + url: `${SEARCH_SERVICE_BASE_URI}/groupIssuesByBundles`, method: "POST", - data: bundleIds, + data: { bundleIds }, }); } diff --git a/src/client/components/ComicDetail/AcquisitionPanel.tsx b/src/client/components/ComicDetail/AcquisitionPanel.tsx index 2a5f9fc..b39d166 100644 --- a/src/client/components/ComicDetail/AcquisitionPanel.tsx +++ b/src/client/components/ComicDetail/AcquisitionPanel.tsx @@ -119,7 +119,7 @@ export const AcquisitionPanel = ( ), ); }, - [], + [airDCPPConfiguration], ); return ( <> diff --git a/src/client/components/ComicDetail/DownloadsPanel.tsx b/src/client/components/ComicDetail/DownloadsPanel.tsx index 9282364..69e740a 100644 --- a/src/client/components/ComicDetail/DownloadsPanel.tsx +++ b/src/client/components/ComicDetail/DownloadsPanel.tsx @@ -57,6 +57,7 @@ export const DownloadsPanel = ( Filename Size Download Time + Bundle ID @@ -72,6 +73,9 @@ export const DownloadsPanel = ( .unix(bundle.time_finished) .format("h:mm on ddd, D MMM, YYYY")} + + {bundle.id} + ))} diff --git a/src/client/components/ComicDetail/TabControls.tsx b/src/client/components/ComicDetail/TabControls.tsx index 87d89cf..a08d300 100644 --- a/src/client/components/ComicDetail/TabControls.tsx +++ b/src/client/components/ComicDetail/TabControls.tsx @@ -10,7 +10,7 @@ export const TabControls = (props): ReactElement => { const [active, setActive] = useState(filteredTabs[0].id); useEffect(() => { - console.log("changed"); + console.log(comicBookDetailData); setActive(filteredTabs[0].id); }, [comicBookDetailData]); @@ -27,12 +27,11 @@ export const TabControls = (props): ReactElement => { {/* Downloads tab and count badge */} {id === 5 && - !isNil(comicBookDetailData) && - !isEmpty(comicBookDetailData) ? ( + !isNil(comicBookDetailData.acquisition.directconnect) ? ( - {comicBookDetailData.acquisition.directconnect.length} + {comicBookDetailData.acquisition.directconnect.downloads.length} ) : ( diff --git a/src/client/components/Dashboard/PullList.tsx b/src/client/components/Dashboard/PullList.tsx index 80896a6..185a6c3 100644 --- a/src/client/components/Dashboard/PullList.tsx +++ b/src/client/components/Dashboard/PullList.tsx @@ -20,7 +20,7 @@ export const PullList = ({ issues }: PullListProps): ReactElement => { useEffect(() => { dispatch( getWeeklyPullList({ - startDate: "2022-7-7", + startDate: "2022-7-29", pageSize: "15", currentPage: "1", }),