import React, { ReactElement, useEffect, useState } from "react"; import { getTransfers } from "../../actions/airdcpp.actions"; import { isEmpty, isNil, isUndefined } from "lodash"; import { determineCoverFile } from "../../shared/utils/metadata.utils"; import MetadataPanel from "../shared/MetadataPanel"; interface IDownloadsProps { data: any; } export const Downloads = (props: IDownloadsProps): ReactElement => { // const airDCPPConfiguration = useContext(AirDCPPSocketContext); const { airDCPPState: { settings, socket }, } = airDCPPConfiguration; // const dispatch = useDispatch(); // const airDCPPTransfers = useSelector( // (state: RootState) => state.airdcpp.transfers, // ); // 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)) { dispatch( getTransfers(socket, { username: `${settings.directConnect.client.host.username}`, password: `${settings.directConnect.client.host.password}`, }), ); } }, [socket]); 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) ? (

Downloads

{bundles.map((bundle, idx) => { return (
{bundle.acquisition.directconnect.downloads.map( (bundle, idx) => { return ( ); }, )}
Name Size Type Bundle ID
{bundle.name} {bundle.size} {bundle.type.str} {bundle.bundleId}
{/*
{JSON.stringify(bundle.acquisition.directconnect.downloads, null, 2)}
*/}
); })}
) : (
There are no downloads.
); }; export default Downloads;