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

move isOwner check to single effect

This commit is contained in:
Matthias Kretschmann 2022-06-23 15:40:59 +01:00
parent 8656a6c51b
commit 2b025ea38c
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -86,7 +86,6 @@ function AssetProvider({
})) }))
setTitle(asset.metadata?.name) setTitle(asset.metadata?.name)
setOwner(asset.nft?.owner) setOwner(asset.nft?.owner)
setIsOwner(accountId?.toLowerCase() === asset?.nft?.owner.toLowerCase())
setIsInPurgatory(asset.purgatory?.state) setIsInPurgatory(asset.purgatory?.state)
setPurgatoryData(asset.purgatory) setPurgatoryData(asset.purgatory)
LoggerInstance.log('[asset] Got asset', asset) LoggerInstance.log('[asset] Got asset', asset)
@ -130,7 +129,6 @@ function AssetProvider({
useEffect(() => { useEffect(() => {
if (!isMounted) return if (!isMounted) return
setIsOwner(accountId?.toLowerCase() === asset?.nft?.owner.toLowerCase())
fetchAccessDetails() fetchAccessDetails()
}, [accountId, fetchAccessDetails, isMounted]) }, [accountId, fetchAccessDetails, isMounted])
@ -144,6 +142,16 @@ function AssetProvider({
setIsAssetNetwork(isAssetNetwork) setIsAssetNetwork(isAssetNetwork)
}, [chainId, asset?.chainId]) }, [chainId, asset?.chainId])
// -----------------------------------
// Asset owner check against wallet user
// -----------------------------------
useEffect(() => {
if (!accountId || !owner) return
const isOwner = accountId?.toLowerCase() === owner.toLowerCase()
setIsOwner(isOwner)
}, [accountId, owner])
// ----------------------------------- // -----------------------------------
// Load ocean config based on asset network // Load ocean config based on asset network
// ----------------------------------- // -----------------------------------