1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-26 03:06:49 +02:00

quick refactor of AssetList data flow

This commit is contained in:
Matthias Kretschmann 2021-10-21 12:31:19 +01:00
parent b6cfe6de34
commit 032b3e1496
Signed by: m
GPG Key ID: 606EEEF3C479A91F
5 changed files with 21 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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 ? (

View File

@ -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,

View File

@ -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,