import { Box, Button, CircularProgress, Divider, LinearProgress, Skeleton, Typography } from '@mui/material';
import React from 'react';
import { messageChannelContext } from '../../../provider/MessageChannel';
import { queueContext } from '../../../provider/QueueProvider';
import useDownloadManager from '../DownloadManager/DownloadManager';
const Queue: React.FC = () => {
const { data, current } = useDownloadManager();
const queue = React.useContext(queueContext);
const msg = React.useContext(messageChannelContext);
if (!msg)
return <>Never>;
return data || queue.length > 0 ? <>
{data && <>
{data.downloadInfo.title}
Language: {data.downloadInfo.language.name}
{data.downloadInfo.parent.title}
{data.progress.cur} / {(data.progress.total)} parts ({data.progress.percent}% | {formatTime(data.progress.time)} | {(data.progress.downloadSpeed / 1024 / 1024).toFixed(2)} MB/s | {(data.progress.bytes / 1024 / 1024).toFixed(2)}MB)
>
}
{
current && !data && <>
{current.title}
Language:
{current.parent.title}
0 / ? parts (0% | X:XX | 0 MB/s | 0MB)
>
}
{queue.length && data && }
{queue.map((queueItem, index, { length }) => {
return
{queueItem.title}
Languages: {queueItem.dubLang.join(', ')}
{queueItem.parent.title}
S{queueItem.parent.season}E{queueItem.episode}
Quality: {queueItem.q}
{index < length - 1 && }
;
})}
> :
Selected episodes will be shown here
;
};
const formatTime = (time: number) => {
time = Math.floor(time / 1000);
const minutes = Math.floor(time / 60);
time = time % 60;
return `${minutes.toFixed(0).length < 2 ? `0${minutes}` : minutes}m${time.toFixed(0).length < 2 ? `0${time}` : time}s`;
};
export default Queue;