frontend performance optimizations
This commit is contained in:
@@ -55,7 +55,7 @@ export default function Layout() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
<SocketSubscriber>
|
<SocketSubscriber />
|
||||||
<Helmet>
|
<Helmet>
|
||||||
<title>
|
<title>
|
||||||
{settings.appTitle}
|
{settings.appTitle}
|
||||||
@@ -174,7 +174,6 @@ export default function Layout() {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Toaster />
|
<Toaster />
|
||||||
</SocketSubscriber>
|
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
Typography
|
Typography
|
||||||
} from '@mui/material'
|
} from '@mui/material'
|
||||||
|
import { useCallback } from 'react'
|
||||||
import { RPCResult } from '../types'
|
import { RPCResult } from '../types'
|
||||||
import { ellipsis, formatSpeedMiB, mapProcessStatus, roundMiB } from '../utils'
|
import { ellipsis, formatSpeedMiB, mapProcessStatus, roundMiB } from '../utils'
|
||||||
|
|
||||||
@@ -34,11 +35,17 @@ const Resolution: React.FC<{ resolution?: string }> = ({ resolution }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DownloadCard: React.FC<Props> = ({ download, onStop, onCopy }) => {
|
const DownloadCard: React.FC<Props> = ({ download, onStop, onCopy }) => {
|
||||||
const isCompleted = () => download.progress.percentage === '-1'
|
const isCompleted = useCallback(
|
||||||
|
() => download.progress.percentage === '-1',
|
||||||
|
[download.progress.percentage]
|
||||||
|
)
|
||||||
|
|
||||||
const percentageToNumber = () => isCompleted()
|
const percentageToNumber = useCallback(
|
||||||
|
() => isCompleted()
|
||||||
? 100
|
? 100
|
||||||
: Number(download.progress.percentage.replace('%', ''))
|
: Number(download.progress.percentage.replace('%', '')),
|
||||||
|
[download.progress.percentage, isCompleted]
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
|
|||||||
@@ -20,13 +20,11 @@ const DownloadsCardView: React.FC = () => {
|
|||||||
{
|
{
|
||||||
downloads.map(download => (
|
downloads.map(download => (
|
||||||
<Grid item xs={4} sm={8} md={6} key={download.id}>
|
<Grid item xs={4} sm={8} md={6} key={download.id}>
|
||||||
<>
|
|
||||||
<DownloadCard
|
<DownloadCard
|
||||||
download={download}
|
download={download}
|
||||||
onStop={() => abort(download.id)}
|
onStop={() => abort(download.id)}
|
||||||
onCopy={() => pushMessage(i18n.t('clipboardAction'), 'info')}
|
onCopy={() => pushMessage(i18n.t('clipboardAction'), 'info')}
|
||||||
/>
|
/>
|
||||||
</>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export default function Splash() {
|
|||||||
const { i18n } = useI18n()
|
const { i18n } = useI18n()
|
||||||
const activeDownloads = useRecoilValue(activeDownloadsState)
|
const activeDownloads = useRecoilValue(activeDownloadsState)
|
||||||
|
|
||||||
if (!activeDownloads || activeDownloads.length !== 0) {
|
if (activeDownloads.length !== 0) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user