code refactoring

This commit is contained in:
2024-03-26 11:34:49 +01:00
parent f2fab66626
commit 15ab37de11
2 changed files with 8 additions and 14 deletions

View File

@@ -1,8 +1,8 @@
import { useEffect } from 'react'
import { useRecoilState, useRecoilValue } from 'recoil'
import { activeDownloadsState, loadingDownloadsState } from '../atoms/downloads'
import { loadingDownloadsState } from '../atoms/downloads'
import { listViewState } from '../atoms/settings'
import { loadingAtom, totalDownloadSpeedState } from '../atoms/ui'
import { loadingAtom } from '../atoms/ui'
import DownloadsCardView from './DownloadsCardView'
import DownloadsTableView from './DownloadsTableView'
@@ -12,15 +12,6 @@ const Downloads: React.FC = () => {
const [isLoading, setIsLoading] = useRecoilState(loadingAtom)
const downloads = useRecoilValue(activeDownloadsState)
const [, setTotalDownloadSpeed] = useRecoilState(totalDownloadSpeedState)
useEffect(() => {
setTotalDownloadSpeed(
downloads.map(d => d.progress.speed).reduce((curr, next) => curr + next, 0)
)
}, [downloads])
useEffect(() => {
if (loadingDownloads) {
return setIsLoading(true)