Skip to content

Commit

Permalink
fix: add a flag to save the first loading status of the FFs (#1051)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo authored Nov 29, 2022
1 parent 3fde6d4 commit a3c65e1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions webapp/src/components/AssetProvider/AssetProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react'
import React, { useEffect, useState } from 'react'
import { AssetType } from '../../modules/asset/types'
import { Props } from './AssetProvider.types'

Expand All @@ -18,11 +18,18 @@ const AssetProvider = (props: Props) => {
isLoadingFeatureFlags
} = props

const [hasLoadedInitialFlags, setHasLoadedInitialFlags] = useState(false)
useEffect(() => {
if (!isLoadingFeatureFlags) {
setHasLoadedInitialFlags(true)
}
}, [isLoadingFeatureFlags])

useEffect(() => {
if (contractAddress && tokenId) {
switch (type) {
case AssetType.NFT:
if (!isLoadingFeatureFlags) {
if (!hasLoadedInitialFlags) {
onFetchNFT(contractAddress, tokenId, { rentalStatus })
}
break
Expand All @@ -40,7 +47,8 @@ const AssetProvider = (props: Props) => {
onFetchNFT,
onFetchItem,
rentalStatus,
isLoadingFeatureFlags
isLoadingFeatureFlags,
hasLoadedInitialFlags
])

return (
Expand All @@ -49,7 +57,7 @@ const AssetProvider = (props: Props) => {
asset,
order,
rental,
isLoading || (isLoadingFeatureFlags && type === AssetType.NFT)
isLoading || (!hasLoadedInitialFlags && type === AssetType.NFT)
)}
</>
)
Expand Down

0 comments on commit a3c65e1

Please sign in to comment.