diff --git a/src/client/actions/airdcpp.actions.tsx b/src/client/actions/airdcpp.actions.tsx index 5a33f37..663bdb2 100644 --- a/src/client/actions/airdcpp.actions.tsx +++ b/src/client/actions/airdcpp.actions.tsx @@ -114,11 +114,10 @@ export const search = }; export const downloadAirDCPPItem = - ( - instanceId: string, - resultId: string, - comicObjectId: string, - comicObject: any, + (searchInstanceId: Number, + resultId: String, + comicObjectId: String, + name: String, size: Number, type: any, ADCPPSocket: any, credentials: any, ): void => @@ -133,22 +132,37 @@ export const downloadAirDCPPItem = } let bundleDBImportResult = {}; const downloadResult = await ADCPPSocket.post( - `search/${instanceId}/results/${resultId}/download`, + `search/${searchInstanceId}/results/${resultId}/download`, ); - - let bundleId; - let directoryIds; - if (!isNil(downloadResult.bundle_info)) { - bundleId = downloadResult.bundle_info.id; - } - if (!isNil(downloadResult.directory_download_ids)) { - directoryIds = downloadResult.directory_download_ids.map( - (item) => item.id, - ); - } if (!isNil(downloadResult)) { + bundleDBImportResult = await axios({ + method: "POST", + url: `${LIBRARY_SERVICE_BASE_URI}/applyAirDCPPDownloadMetadata`, + headers: { + "Content-Type": "application/json; charset=utf-8", + }, + data: { + bundleId: downloadResult.bundle_info.id, + comicObjectId, + name, + size, + type, + }, + }); + + dispatch({ + type: AIRDCPP_RESULT_DOWNLOAD_INITIATED, + downloadResult, + bundleDBImportResult, + }); + dispatch({ + type: IMS_COMIC_BOOK_DB_OBJECT_FETCHED, + comicBookDetail: bundleDBImportResult.data, + IMS_inProgress: false, + }); + } } catch (error) { throw error; diff --git a/src/client/components/App.tsx b/src/client/components/App.tsx index 0eb686c..db257dc 100644 --- a/src/client/components/App.tsx +++ b/src/client/components/App.tsx @@ -42,32 +42,7 @@ const AirDCPPSocketComponent = (): ReactElement => { "queue_bundle_added", async (data) => { console.log("JEMEN:", data); - const { id, name, size, target, time_added, type } = data; - const downloadResultMetadata = await axios({ - method: "POST", - url: `${LIBRARY_SERVICE_BASE_URI}/applyAirDCPPDownloadMetadata`, - headers: { - "Content-Type": "application/json; charset=utf-8", - }, - data: { - bundleId: id, - name, - size, - target, - time_added, - type - }, - }); - // dispatch({ - // type: AIRDCPP_RESULT_DOWNLOAD_INITIATED, - // downloadResult: downloadResult, - // bundleDBImportResult, - // }); - // dispatch({ - // type: IMS_COMIC_BOOK_DB_OBJECT_FETCHED, - // comicBookDetail: bundleDBImportResult.data, - // IMS_inProgress: false, - // }); + } ); diff --git a/src/client/components/ComicDetail/AcquisitionPanel.tsx b/src/client/components/ComicDetail/AcquisitionPanel.tsx index 0031428..97d0c3d 100644 --- a/src/client/components/ComicDetail/AcquisitionPanel.tsx +++ b/src/client/components/ComicDetail/AcquisitionPanel.tsx @@ -18,7 +18,7 @@ import { isEmpty, isNil, map } from "lodash"; import { AirDCPPSocketContext } from "../../context/AirDCPPSocket"; interface IAcquisitionPanelProps { query: any; - comicObjectid: any; + comicObjectId: any; comicObject: any; settings: any; } @@ -93,13 +93,12 @@ export const AcquisitionPanel = ( // download via AirDC++ const downloadDCPPResult = useCallback( - (searchInstanceId, resultId, comicBookObjectId, comicObject) => { + (searchInstanceId, resultId, name, size, type) => { dispatch( downloadAirDCPPItem( - searchInstanceId, - resultId, - comicBookObjectId, - comicObject, + searchInstanceId, resultId, + props.comicObjectId, + name, size, type, airDCPPConfiguration.airDCPPState.socket, { username: `${airDCPPConfiguration.airDCPPState.settings.directConnect.client.host.username}`, @@ -110,7 +109,7 @@ export const AcquisitionPanel = ( // this is to update the download count badge on the downloads tab dispatch( getBundlesForComic( - comicBookObjectId, + props.comicObjectId, airDCPPConfiguration.airDCPPState.socket, { username: `${airDCPPConfiguration.airDCPPState.settings.directConnect.client.host.username}`, @@ -245,7 +244,6 @@ export const AcquisitionPanel = ( {map(airDCPPSearchResults, ({ result }, idx) => { - console.log(result); return ( diff --git a/src/client/components/ComicDetail/ComicDetail.tsx b/src/client/components/ComicDetail/ComicDetail.tsx index e514360..92f79a7 100644 --- a/src/client/components/ComicDetail/ComicDetail.tsx +++ b/src/client/components/ComicDetail/ComicDetail.tsx @@ -182,7 +182,7 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => { content: ( { margin: "0 0 8px 0", }} /> -
{JSON.stringify(bundle.acquisition.directconnect.downloads, null, 2)}
+ + + + + + + + + {bundle.acquisition.directconnect.downloads.map((bundle) => { + return( + + + + + ) + })} +
NameSizeTypeBundle ID
{bundle.name}{bundle.size}{bundle.type.str}{bundle.bundleId}
+ {/*
{JSON.stringify(bundle.acquisition.directconnect.downloads, null, 2)}
*/} })}