1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

fix checkIsConsumable dependencies (#788)

This commit is contained in:
Matthias Kretschmann 2021-08-16 13:02:01 +03:00 committed by GitHub
parent e2bb8fc042
commit fd06afc9f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,9 +30,10 @@ export default function AssetActions(): ReactElement {
const [consumableFeedback, setConsumableFeedback] = useState<string>('') const [consumableFeedback, setConsumableFeedback] = useState<string>('')
useEffect(() => { useEffect(() => {
if (!ddo || !accountId) return if (!ddo || !accountId || !ocean || !isAssetNetwork) return
async function checkIsConsumable() { async function checkIsConsumable() {
const consumable: any = await ocean.assets.isConsumable( const consumable = await ocean.assets.isConsumable(
ddo, ddo,
accountId.toLowerCase() accountId.toLowerCase()
) )
@ -42,11 +43,13 @@ export default function AssetActions(): ReactElement {
} }
} }
checkIsConsumable() checkIsConsumable()
}, [accountId, ddo]) }, [accountId, isAssetNetwork, ddo, ocean])
useEffect(() => { useEffect(() => {
if (!config) return if (!config) return
const source = axios.CancelToken.source() const source = axios.CancelToken.source()
async function initFileInfo() { async function initFileInfo() {
setFileIsLoading(true) setFileIsLoading(true)
try { try {
@ -60,11 +63,12 @@ export default function AssetActions(): ReactElement {
} catch (error) { } catch (error) {
Logger.error(error.message) Logger.error(error.message)
} finally { } finally {
// this triggers a memory leak warrning, no idea how to fix // this triggers a memory leak warning, no idea how to fix
setFileIsLoading(false) setFileIsLoading(false)
} }
} }
initFileInfo() initFileInfo()
return () => { return () => {
source.cancel() source.cancel()
} }