import { useTranslation } from "next-i18next"; import QueueEntry from "../../components/widgets/queue/queueEntry"; import Container from "components/services/widget/container"; import Block from "components/services/widget/block"; import useWidgetAPI from "utils/proxy/use-widget-api"; export default function Component({ service }) { const { t } = useTranslation(); const { widget } = service; const { data: torrentData, error: torrentError } = useWidgetAPI(widget, "torrents"); if (torrentError) { return ; } if (!torrentData) { return ( ); } let rateDl = 0; let rateUl = 0; let completed = 0; const leechTorrents = []; for (let i = 0; i < torrentData.length; i += 1) { const torrent = torrentData[i]; rateDl += torrent.dlspeed; rateUl += torrent.upspeed; if (torrent.progress === 1) { completed += 1; } if (torrent.state.includes("DL") || torrent.state === "downloading") { leechTorrents.push(torrent); } } const leech = torrentData.length - completed; return ( <> {widget?.enableLeechProgress && leechTorrents.map((queueEntry) => ( ))} ); }