Commit ed8afbd8 authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

fix: App crashing when changing sorting or toggling usd price on trneding NFTs table (#6354)

* fix app breaking when changing sorting or toggling usd price

* compare floor change correctly

---------
Co-authored-by: default avatarCharles Bachmeier <charlie@genie.xyz>
parent 47b6a7c4
......@@ -114,8 +114,8 @@ export const EthCell = ({
denomination: Denomination
usdPrice?: number
}) => {
const denominatedValue = getDenominatedValue(denomination, true, value, usdPrice)
const isNftGraphqlEnabled = useNftGraphqlEnabled()
const denominatedValue = getDenominatedValue(denomination, !isNftGraphqlEnabled, value, usdPrice)
const formattedValue = denominatedValue
? denomination === Denomination.ETH
? isNftGraphqlEnabled
......
import { BigNumber } from '@ethersproject/bignumber'
import { useNftGraphqlEnabled } from 'featureFlags/flags/nftlGraphql'
import { CollectionTableColumn, TimePeriod } from 'nft/types'
import { useMemo } from 'react'
import { CellProps, Column, Row } from 'react-table'
......@@ -26,14 +27,19 @@ const compareFloats = (a?: number, b?: number): 1 | -1 => {
}
const CollectionTable = ({ data, timePeriod }: { data: CollectionTableColumn[]; timePeriod: TimePeriod }) => {
const isNftGraphqlEnabled = useNftGraphqlEnabled()
const floorSort = useMemo(() => {
return (rowA: Row<CollectionTableColumn>, rowB: Row<CollectionTableColumn>) => {
const aFloor = BigNumber.from(rowA.original.floor.value ?? 0)
const bFloor = BigNumber.from(rowB.original.floor.value ?? 0)
if (isNftGraphqlEnabled) {
return compareFloats(rowA.original.floor.value, rowB.original.floor.value)
} else {
const aFloor = BigNumber.from(rowA.original.floor.value ?? 0)
const bFloor = BigNumber.from(rowB.original.floor.value ?? 0)
return aFloor.gte(bFloor) ? 1 : -1
return aFloor.gte(bFloor) ? 1 : -1
}
}
}, [])
}, [isNftGraphqlEnabled])
const floorChangeSort = useMemo(() => {
return (rowA: Row<CollectionTableColumn>, rowB: Row<CollectionTableColumn>) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment