mirror of
https://github.com/oceanprotocol/market.git
synced 2024-06-30 13:51:42 +02:00
* wip * get latest assets from multiple networks * updated queryMetadata function in components * added new multinetwork aquarius api * Use ddo chainId for AssetType inside teaser * added chainId filter to queries from home page * put chainId query string in parenthesis * search filter by chainIds * updated getDoo and getAssetName functions * removed logs and fixed lint errors * updated get published assets query * adapted bookmarks aquarius call to multinetwork * removed temporary ddo Co-authored-by: Norbi <katunanorbert@gmai.com>
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { DDO } from '@oceanprotocol/lib'
|
|
import { useOcean } from '../../providers/Ocean'
|
|
import { Link } from 'gatsby'
|
|
import React, { ReactElement, useEffect, useState } from 'react'
|
|
import { getAssetsNames } from '../../utils/aquarius'
|
|
import styles from './AssetListTitle.module.css'
|
|
import axios from 'axios'
|
|
import { useSiteMetadata } from '../../hooks/useSiteMetadata'
|
|
|
|
export default function AssetListTitle({
|
|
ddo,
|
|
did,
|
|
title
|
|
}: {
|
|
ddo?: DDO
|
|
did?: string
|
|
title?: string
|
|
}): ReactElement {
|
|
const { appConfig } = useSiteMetadata()
|
|
const [assetTitle, setAssetTitle] = useState<string>(title)
|
|
|
|
useEffect(() => {
|
|
if (title || !appConfig.metadataCacheUri) return
|
|
if (ddo) {
|
|
const { attributes } = ddo.findServiceByType('metadata')
|
|
setAssetTitle(attributes.main.name)
|
|
return
|
|
}
|
|
|
|
const source = axios.CancelToken.source()
|
|
|
|
async function getAssetName() {
|
|
const title = await getAssetsNames([did], source.token)
|
|
setAssetTitle(title[did])
|
|
}
|
|
|
|
!ddo && did && getAssetName()
|
|
|
|
return () => {
|
|
source.cancel()
|
|
}
|
|
}, [assetTitle, appConfig.metadataCacheUri, ddo, did, title])
|
|
|
|
return (
|
|
<h3 className={styles.title}>
|
|
<Link to={`/asset/${did || ddo.id}`}>{assetTitle}</Link>
|
|
</h3>
|
|
)
|
|
}
|