mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
quick refactor of AssetList data flow
This commit is contained in:
parent
b6cfe6de34
commit
032b3e1496
1
src/@types/aquarius/BaseQueryParams.d.ts
vendored
1
src/@types/aquarius/BaseQueryParams.d.ts
vendored
@ -5,6 +5,7 @@ interface EsPaginationOptions {
|
||||
|
||||
interface BaseQueryParams {
|
||||
chainIds: number[]
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
nestedQuery?: any
|
||||
esPaginationOptions?: EsPaginationOptions
|
||||
sortOptions?: SortOptions
|
||||
|
@ -9,6 +9,10 @@ import { PriceList, getAssetsPriceList } from './subgraph'
|
||||
import axios, { CancelToken, AxiosResponse } from 'axios'
|
||||
import { OrdersData_tokenOrders as OrdersData } from '../@types/apollo/OrdersData'
|
||||
import { metadataCacheUri } from '../../app.config'
|
||||
import {
|
||||
SortDirectionOptions,
|
||||
SortTermOptions
|
||||
} from '../@types/aquarius/SearchQuery'
|
||||
|
||||
export const MAXIMUM_NUMBER_OF_PAGES_WITH_RESULTS = 476
|
||||
|
||||
|
@ -41,22 +41,27 @@ const AssetList: React.FC<AssetListProps> = ({
|
||||
noPublisher
|
||||
}) => {
|
||||
const { chainIds } = useUserPreferences()
|
||||
const [assetsWithPrices, setAssetWithPrices] = useState<AssetListPrices[]>()
|
||||
const [loading, setLoading] = useState<boolean>(true)
|
||||
const [assetsWithPrices, setAssetsWithPrices] = useState<AssetListPrices[]>()
|
||||
const [loading, setLoading] = useState<boolean>(isLoading)
|
||||
const isMounted = useIsMounted()
|
||||
|
||||
useEffect(() => {
|
||||
if (!assets) return
|
||||
isLoading && setLoading(true)
|
||||
|
||||
const initialAssets: AssetListPrices[] = assets.map((asset) => ({
|
||||
ddo: asset,
|
||||
price: null
|
||||
}))
|
||||
setAssetsWithPrices(initialAssets)
|
||||
setLoading(false)
|
||||
|
||||
async function fetchPrices() {
|
||||
const asset = await getAssetsBestPrices(assets)
|
||||
const assetsWithPrices = await getAssetsBestPrices(assets)
|
||||
if (!isMounted()) return
|
||||
setAssetWithPrices(asset)
|
||||
setLoading(false)
|
||||
setAssetsWithPrices(assetsWithPrices)
|
||||
}
|
||||
|
||||
fetchPrices()
|
||||
}, [assets])
|
||||
}, [assets, isMounted])
|
||||
|
||||
// // This changes the page field inside the query
|
||||
function handlePageChange(selected: number) {
|
||||
@ -72,9 +77,7 @@ const AssetList: React.FC<AssetListProps> = ({
|
||||
<div className={styleClasses}>
|
||||
<div className={styles.empty}>No network selected</div>
|
||||
</div>
|
||||
) : assetsWithPrices &&
|
||||
!loading &&
|
||||
(isLoading === undefined || isLoading === false) ? (
|
||||
) : assetsWithPrices && !loading ? (
|
||||
<>
|
||||
<div className={styleClasses}>
|
||||
{assetsWithPrices.length > 0 ? (
|
||||
|
@ -38,6 +38,7 @@ import AssetActionHistoryTable from '../AssetActionHistoryTable'
|
||||
import ComputeJobs from '../../../Profile/History/ComputeJobs'
|
||||
import { useCancelToken } from '@hooks/useCancelToken'
|
||||
import { useIsMounted } from '@hooks/useIsMounted'
|
||||
import { SortTermOptions } from '../../../../@types/aquarius/SearchQuery'
|
||||
|
||||
export default function Compute({
|
||||
dtBalance,
|
||||
|
@ -15,6 +15,7 @@ import { publisherTrustedAlgorithm as PublisherTrustedAlgorithm } from '@oceanpr
|
||||
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
||||
import FormActions from './FormActions'
|
||||
import { useCancelToken } from '@hooks/useCancelToken'
|
||||
import { SortTermOptions } from '../../../../@types/aquarius/SearchQuery'
|
||||
|
||||
export default function FormEditComputeDataset({
|
||||
data,
|
||||
|
Loading…
Reference in New Issue
Block a user