code refactoring
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user