import { Badge, Box, Button, CircularProgress, Divider, IconButton, LinearProgress, Skeleton, Tooltip, Typography } from '@mui/material';
import React from 'react';
import { messageChannelContext } from '../../../provider/MessageChannel';
import { queueContext } from '../../../provider/QueueProvider';
import DeleteIcon from '@mui/icons-material/Delete';
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.parent.title}
{data.downloadInfo.title}
Downloading: {data.downloadInfo.language.name}
{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.parent.title}
{current.title}
Downloading:
0 / ? parts (0% | XX:XX | 0 MB/s | 0MB)
>
}
{queue.map((queueItem, index, { length }) => {
return
{queueItem.parent.title}
S{queueItem.parent.season}E{queueItem.episode}
{queueItem.title}
Dub(s): {queueItem.dubLang.join(', ')}
Sub(s): {queueItem.dlsubs.join(', ')}
Quality: {queueItem.q}
{
msg.removeFromQueue(index);
}}
sx={{
backgroundColor: '#ff573a25',
height: '40px',
transition: '250ms',
'&:hover' : {
backgroundColor: '#ff573a',
}
}}>
;
})}
> :
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;