code refactoring
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import { Grid } from "@mui/material"
|
import { Grid } from "@mui/material"
|
||||||
import { Fragment } from "react"
|
import { Fragment } from "react"
|
||||||
|
|
||||||
import type { RPCResult } from "../types"
|
import type { RPCResult } from "../types"
|
||||||
import { StackableResult } from "./StackableResult"
|
import { StackableResult } from "./StackableResult"
|
||||||
|
|
||||||
@@ -17,6 +16,7 @@ export function DownloadsCardView({ downloads, abortFunction }: Props) {
|
|||||||
<Grid item xs={4} sm={8} md={6} key={download.id}>
|
<Grid item xs={4} sm={8} md={6} key={download.id}>
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<StackableResult
|
<StackableResult
|
||||||
|
url={download.info.url}
|
||||||
title={download.info.title}
|
title={download.info.title}
|
||||||
thumbnail={download.info.thumbnail}
|
thumbnail={download.info.thumbnail}
|
||||||
percentage={download.progress.percentage}
|
percentage={download.progress.percentage}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { ellipsis, formatSpeedMiB, roundMiB } from '../utils'
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title: string,
|
title: string,
|
||||||
|
url: string,
|
||||||
thumbnail: string,
|
thumbnail: string,
|
||||||
resolution: string
|
resolution: string
|
||||||
percentage: string,
|
percentage: string,
|
||||||
@@ -27,6 +28,7 @@ type Props = {
|
|||||||
|
|
||||||
export function StackableResult({
|
export function StackableResult({
|
||||||
title,
|
title,
|
||||||
|
url,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
resolution,
|
resolution,
|
||||||
percentage,
|
percentage,
|
||||||
@@ -45,17 +47,17 @@ export function StackableResult({
|
|||||||
const percentageToNumber = () => isCompleted ? 100 : Number(percentage.replace('%', ''))
|
const percentageToNumber = () => isCompleted ? 100 : Number(percentage.replace('%', ''))
|
||||||
|
|
||||||
const guessResolution = (xByY: string): any => {
|
const guessResolution = (xByY: string): any => {
|
||||||
if (!xByY) return null;
|
if (!xByY) return null
|
||||||
if (xByY.includes('4320')) return (<EightK color="primary" />);
|
if (xByY.includes('4320')) return (<EightK color="primary" />)
|
||||||
if (xByY.includes('2160')) return (<FourK color="primary" />);
|
if (xByY.includes('2160')) return (<FourK color="primary" />)
|
||||||
if (xByY.includes('1080')) return (<Hd color="primary" />);
|
if (xByY.includes('1080')) return (<Hd color="primary" />)
|
||||||
if (xByY.includes('720')) return (<Sd color="primary" />);
|
if (xByY.includes('720')) return (<Sd color="primary" />)
|
||||||
return null;
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardActionArea>
|
<CardActionArea onClick={() => navigator.clipboard.writeText(url)}>
|
||||||
{thumbnail !== '' ?
|
{thumbnail !== '' ?
|
||||||
<CardMedia
|
<CardMedia
|
||||||
component="img"
|
component="img"
|
||||||
|
|||||||
Reference in New Issue
Block a user