From ec8cd2063304bce80a9148e927f9441e54068b46 Mon Sep 17 00:00:00 2001 From: Preschian Febryantara Date: Fri, 15 Mar 2024 15:34:07 +0700 Subject: [PATCH 1/2] fix: genart carousel --- .../carousel/utils/useCarouselEvents.ts | 42 +++++++++++++------ utils/drop.ts | 4 +- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/components/carousel/utils/useCarouselEvents.ts b/components/carousel/utils/useCarouselEvents.ts index c2ef2c7828..d503e8c45d 100644 --- a/components/carousel/utils/useCarouselEvents.ts +++ b/components/carousel/utils/useCarouselEvents.ts @@ -2,7 +2,8 @@ import type { CarouselNFT } from '@/components/base/types' import type { NFTWithMetadata } from '@/composables/useNft' import type { Prefix } from '@kodadot1/static' import { formatNFT } from '@/utils/carousel' -import { AHK_GENERATIVE_DROPS, AHP_GENERATIVE_DROPS } from '@/utils/drop' +import { AHK_GENERATIVE_DROPS } from '@/utils/drop' +import { getDrops } from '@/services/fxart' import latestEvents from '@/queries/subsquid/general/latestEvents.graphql' import latestEventsRmrkv2 from '@/queries/subsquid/ksm/latestEvents.graphql' @@ -182,7 +183,7 @@ const GENERATIVE_CONFIG: Partial< > = { ahp: { limit: 12, - collections: AHP_GENERATIVE_DROPS, + collections: [], }, ahk: { limit: 3, @@ -193,21 +194,38 @@ const GENERATIVE_CONFIG: Partial< export const useCarouselGenerativeNftEvents = () => { const nfts = ref([]) const eventType = ['newestList', 'latestSales'] + const dropsAhp = computedAsync(async () => { + return await getDrops({ + limit: 12, + active: [true], + chain: ['ahp'], + }) + }) + + const eventsDataRefs = computed(() => { + return Object.keys(GENERATIVE_CONFIG).map((chain) => { + let collections = GENERATIVE_CONFIG[chain].collections + + if (chain === 'ahp' && dropsAhp.value?.length) { + collections = dropsAhp.value.map((drop) => drop.collection) + } - const eventsDataRefs = Object.keys(GENERATIVE_CONFIG).map((chain) => { - return eventType.map((eventName) => { - const { data } = useEvents( - chain, - eventName, - GENERATIVE_CONFIG[chain].limit, - GENERATIVE_CONFIG[chain].collections, - ) - return data + console.log('dropsAhp', chain, collections) + + return eventType.map((eventName) => { + const { data } = useEvents( + chain, + eventName, + GENERATIVE_CONFIG[chain].limit, + collections, + ) + return data + }) }) }) watchEffect(() => { - nfts.value = eventsDataRefs.flat().flatMap((dataRef) => dataRef.value) + nfts.value = eventsDataRefs.value.flat().flatMap((dataRef) => dataRef.value) }) return computed(() => sortNfts(unionBy(nfts.value, 'id')).nfts) diff --git a/utils/drop.ts b/utils/drop.ts index fd84ecb03d..e79d3d07a9 100644 --- a/utils/drop.ts +++ b/utils/drop.ts @@ -20,7 +20,7 @@ export const AHK_GENERATIVE_DROPS = [ '176', // Chained ] -export const AHP_GENERATIVE_DROPS = [ +export const AHP_POPULAR_DROP_COLLECTIONS = [ '108', // Motifs '106', // Refraction '99', // Leadlight @@ -42,8 +42,6 @@ export const AHP_GENERATIVE_DROPS = [ '38', // Generativ Art - Pare1d0scope ] -export const AHP_POPULAR_DROP_COLLECTIONS = [...AHP_GENERATIVE_DROPS] - export const FALLBACK_DROP_COLLECTION_MAX = 300 export const FUTURE_DROP_DATE = new Date(Date.UTC(2024, 0, 25, 14, 0, 0)) From a0c9142e544d81ccfd7da398160a5308788867ef Mon Sep 17 00:00:00 2001 From: Preschian Febryantara Date: Sat, 16 Mar 2024 16:49:52 +0700 Subject: [PATCH 2/2] feat(useCarouselEvents.ts): add production check for 'ahk' chain fix(useCarouselEvents.ts): remove console.log for 'dropsAhp' chain and collections --- components/carousel/utils/useCarouselEvents.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/carousel/utils/useCarouselEvents.ts b/components/carousel/utils/useCarouselEvents.ts index d503e8c45d..7c73cdced8 100644 --- a/components/carousel/utils/useCarouselEvents.ts +++ b/components/carousel/utils/useCarouselEvents.ts @@ -206,12 +206,14 @@ export const useCarouselGenerativeNftEvents = () => { return Object.keys(GENERATIVE_CONFIG).map((chain) => { let collections = GENERATIVE_CONFIG[chain].collections + if (isProduction && chain === 'ahk') { + return [] + } + if (chain === 'ahp' && dropsAhp.value?.length) { collections = dropsAhp.value.map((drop) => drop.collection) } - console.log('dropsAhp', chain, collections) - return eventType.map((eventName) => { const { data } = useEvents( chain,