mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-20 05:56:10 +05:00
fixed memory leak
This commit is contained in:
@@ -36,7 +36,7 @@ export const useUpdateCache = hash => {
|
|||||||
return cache
|
return cache
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useCreateCacheMap = (cache, callback) => {
|
export const useCreateCacheMap = cache => {
|
||||||
const [cacheMap, setCacheMap] = useState([])
|
const [cacheMap, setCacheMap] = useState([])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -67,8 +67,7 @@ export const useCreateCacheMap = (cache, callback) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setCacheMap(map)
|
setCacheMap(map)
|
||||||
callback && callback()
|
}, [cache])
|
||||||
}, [cache, callback])
|
|
||||||
|
|
||||||
return cacheMap
|
return cacheMap
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { NoImageIcon } from 'icons'
|
|||||||
import { getPeerString, humanizeSize } from 'utils/Utils'
|
import { getPeerString, humanizeSize } from 'utils/Utils'
|
||||||
import { viewedHost } from 'utils/Hosts'
|
import { viewedHost } from 'utils/Hosts'
|
||||||
import { CopyToClipboard } from 'react-copy-to-clipboard'
|
import { CopyToClipboard } from 'react-copy-to-clipboard'
|
||||||
import { useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
import { useUpdateCache, useCreateCacheMap } from './customHooks'
|
import { useUpdateCache, useCreateCacheMap } from './customHooks'
|
||||||
|
|
||||||
@@ -116,7 +116,9 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
|
|||||||
} = torrent
|
} = torrent
|
||||||
|
|
||||||
const cache = useUpdateCache(hash)
|
const cache = useUpdateCache(hash)
|
||||||
const cacheMap = useCreateCacheMap(cache, () => setIsLoading(false))
|
const cacheMap = useCreateCacheMap(cache)
|
||||||
|
|
||||||
|
useEffect(() => setIsLoading(false), [cacheMap])
|
||||||
|
|
||||||
const { Capacity, PiecesCount, PiecesLength } = cache
|
const { Capacity, PiecesCount, PiecesLength } = cache
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user