From 611c52971830b9fc0ca8857c93683bfe2d1ddd06 Mon Sep 17 00:00:00 2001 From: Daniel Shleifman Date: Fri, 28 May 2021 17:52:43 +0300 Subject: [PATCH] drop torrent added --- .../DialogTorrentDetailsContent/index.jsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/web/src/components/DialogTorrentDetailsContent/index.jsx b/web/src/components/DialogTorrentDetailsContent/index.jsx index b7c2c91..675365e 100644 --- a/web/src/components/DialogTorrentDetailsContent/index.jsx +++ b/web/src/components/DialogTorrentDetailsContent/index.jsx @@ -50,18 +50,17 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) { const cacheMap = useCreateCacheMap(cache) const settings = useGetSettings(cache) - const dropTorrent = hash => { - axios.post(torrentsHost(), { action: 'drop', hash }).then(() => console.log('torrent dropped')) - } + const dropTorrent = hash => axios.post(torrentsHost(), { action: 'drop', hash }) const { Capacity, PiecesCount, PiecesLength, Filled } = cache useEffect(() => { - const cacheIsLoading = !Object.entries(cache).length + const cacheLoaded = !!Object.entries(cache).length + const torrentLoaded = torrent.stat_string !== 'Torrent in db' && torrent.stat_string !== 'Torrent getting info' - if (cacheIsLoading && !isLoading) setIsLoading(true) - if (!cacheIsLoading && isLoading) setIsLoading(false) - }, [cache, isLoading]) + if (!cacheLoaded && !isLoading) setIsLoading(true) + if (cacheLoaded && isLoading && torrentLoaded) setIsLoading(false) + }, [torrent, cache, isLoading]) const bufferSize = settings?.PreloadBuffer ? Capacity : 33554432 // Default is 32mb if PreloadBuffer is false