mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Display highest liquidity assets fix (#802)
* correct offset set, empty result for no network selected * network-only policy used, logs deleted * cache and network policy used * Update src/components/pages/Home.tsx Co-authored-by: Matthias Kretschmann <m@kretschmann.io> Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
This commit is contained in:
parent
e500772d21
commit
e703f9b03d
@ -21,10 +21,10 @@ import styles from './Home.module.css'
|
||||
async function getQueryHighest(
|
||||
chainIds: number[]
|
||||
): Promise<[SearchQuery, string]> {
|
||||
const dids = await getHighestLiquidityDIDs(chainIds)
|
||||
const [dids, didsLength] = await getHighestLiquidityDIDs(chainIds)
|
||||
const queryHighest = {
|
||||
page: 1,
|
||||
offset: dids.length,
|
||||
offset: didsLength,
|
||||
query: {
|
||||
query_string: {
|
||||
query: `(${dids}) AND (${transformChainIdsListToQuery(
|
||||
@ -72,6 +72,7 @@ function SectionQueryResult({
|
||||
queryData?: string
|
||||
}) {
|
||||
const { appConfig } = useSiteMetadata()
|
||||
const { chainIds } = useUserPreferences()
|
||||
const [result, setResult] = useState<QueryResult>()
|
||||
const [loading, setLoading] = useState<boolean>()
|
||||
|
||||
@ -80,6 +81,16 @@ function SectionQueryResult({
|
||||
const source = axios.CancelToken.source()
|
||||
|
||||
async function init() {
|
||||
if (chainIds.length === 0) {
|
||||
const result: QueryResult = {
|
||||
results: [],
|
||||
page: 0,
|
||||
totalPages: 0,
|
||||
totalResults: 0
|
||||
}
|
||||
setResult(result)
|
||||
setLoading(false)
|
||||
} else {
|
||||
try {
|
||||
setLoading(true)
|
||||
const result = await queryMetadata(query, source.token)
|
||||
@ -93,7 +104,8 @@ function SectionQueryResult({
|
||||
setResult(result)
|
||||
setLoading(false)
|
||||
} catch (error) {
|
||||
Logger.log(error.message)
|
||||
Logger.error(error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
init()
|
||||
|
@ -151,7 +151,7 @@ export function getQueryContext(chainId: number): OperationContext {
|
||||
url: `${getSubgraphUri(
|
||||
Number(chainId)
|
||||
)}/subgraphs/name/oceanprotocol/ocean-subgraph`,
|
||||
requestPolicy: 'cache-first'
|
||||
requestPolicy: 'cache-and-network'
|
||||
}
|
||||
|
||||
return queryContext
|
||||
@ -469,7 +469,7 @@ export async function getAssetsBestPrices(
|
||||
|
||||
export async function getHighestLiquidityDIDs(
|
||||
chainIds: number[]
|
||||
): Promise<string> {
|
||||
): Promise<[string, number]> {
|
||||
const didList: string[] = []
|
||||
let highestLiquidiyAssets: HighestLiquidityAssetsPools[] = []
|
||||
for (const chain of chainIds) {
|
||||
@ -495,5 +495,5 @@ export async function getHighestLiquidityDIDs(
|
||||
.replace(/"/g, '')
|
||||
.replace(/(\[|\])/g, '')
|
||||
.replace(/(did:op:)/g, '0x')
|
||||
return searchDids
|
||||
return [searchDids, didList.length]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user