Skip to content

Commit a3c65e1

Browse files
fix: add a flag to save the first loading status of the FFs (#1051)
1 parent 3fde6d4 commit a3c65e1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

webapp/src/components/AssetProvider/AssetProvider.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react'
1+
import React, { useEffect, useState } from 'react'
22
import { AssetType } from '../../modules/asset/types'
33
import { Props } from './AssetProvider.types'
44

@@ -18,11 +18,18 @@ const AssetProvider = (props: Props) => {
1818
isLoadingFeatureFlags
1919
} = props
2020

21+
const [hasLoadedInitialFlags, setHasLoadedInitialFlags] = useState(false)
22+
useEffect(() => {
23+
if (!isLoadingFeatureFlags) {
24+
setHasLoadedInitialFlags(true)
25+
}
26+
}, [isLoadingFeatureFlags])
27+
2128
useEffect(() => {
2229
if (contractAddress && tokenId) {
2330
switch (type) {
2431
case AssetType.NFT:
25-
if (!isLoadingFeatureFlags) {
32+
if (!hasLoadedInitialFlags) {
2633
onFetchNFT(contractAddress, tokenId, { rentalStatus })
2734
}
2835
break
@@ -40,7 +47,8 @@ const AssetProvider = (props: Props) => {
4047
onFetchNFT,
4148
onFetchItem,
4249
rentalStatus,
43-
isLoadingFeatureFlags
50+
isLoadingFeatureFlags,
51+
hasLoadedInitialFlags
4452
])
4553

4654
return (
@@ -49,7 +57,7 @@ const AssetProvider = (props: Props) => {
4957
asset,
5058
order,
5159
rental,
52-
isLoading || (isLoadingFeatureFlags && type === AssetType.NFT)
60+
isLoading || (!hasLoadedInitialFlags && type === AssetType.NFT)
5361
)}
5462
</>
5563
)

0 commit comments

Comments
 (0)