import React, { useEffect, ReactElement } from "react"; import { getDownloadProgress, getBundlesForComic, } from "../actions/airdcpp.actions"; import { useDispatch, useSelector } from "react-redux"; import { RootState } from "threetwo-ui-typings"; import { isNil, map } from "lodash"; import prettyBytes from "pretty-bytes"; interface IDownloadsPanelProps { data: any; } export const DownloadsPanel = ( props: IDownloadsPanelProps, ): ReactElement | null => { const downloadProgressTick = useSelector( (state: RootState) => state.airdcpp.downloadProgressData, ); const bundles = useSelector((state: RootState) => state.airdcpp.bundles); const dispatch = useDispatch(); // useEffect(() => { // dispatch(getDownloadProgress(props.data._id)); // }, [dispatch]); useEffect(() => { dispatch(getBundlesForComic(props.data._id)); }, [dispatch]); const ProgressTick = (props) => (
{JSON.stringify(props.downloadProgressTick)} {(parseInt(props.downloaded_bytes) / parseInt(props.size)) * 100}%
{props.name}
{prettyBytes(props.downloaded_bytes)} of {prettyBytes(props.size)}
{prettyBytes(props.speed)} per second. Time left: {parseInt(props.seconds_left) / 60}
{props.target}
); const Bundles = (props) => { return (
{!isNil(props.data) && props.data && map(props.data, (bundle) => ( <>
{bundle.name}
{bundle.target}
{bundle.size}
))}
); }; return !isNil(bundles) ? : null; }; export default DownloadsPanel;