Skip to content

Commit

Permalink
fix: remove the cancel logic from the BestBuyingOption main useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Nov 30, 2023
1 parent bbaff49 commit 59501ea
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const BestBuyingOption = ({ asset, tableRef }: Props) => {
}

useEffect(() => {
let cancel = false
if (asset && !isNFT(asset)) {
if (asset.available > 0 && asset.isOnSale) {
setBuyOption(BuyOptions.MINT)
Expand All @@ -76,7 +75,6 @@ const BestBuyingOption = ({ asset, tableRef }: Props) => {
.fetchOrders(params, sortBy)
.then(response => {
if (response.data.length > 0) {
if (cancel) return
setBuyOption(BuyOptions.BUY_LISTING)
setListing({ order: response.data[0], total: response.total })
bidAPI
Expand All @@ -88,28 +86,23 @@ const BestBuyingOption = ({ asset, tableRef }: Props) => {
'1'
)
.then(response => {
if (cancel) return
setIsLoading(false)
setMostExpensiveBid(response.data[0])
})
.catch(error => {
if (!cancel) setIsLoading(false)
console.error(error)
setIsLoading(false)
})
} else {
if (cancel) return
setIsLoading(false)
}
})
.catch(error => {
if (!cancel) setIsLoading(false)
console.error(error)
setIsLoading(false)
})
}
}
return () => {
cancel = true
}
}, [asset, listing])

const customClasses = {
Expand All @@ -119,6 +112,7 @@ const BestBuyingOption = ({ asset, tableRef }: Props) => {
buyWithCardClassName: styles.buyWithCardClassName
}

console.log('isLoading: ', isLoading)
return isLoading ? null : (
<div
data-testid="best-buying-option-container"
Expand Down

0 comments on commit 59501ea

Please sign in to comment.