Skip to content

Commit

Permalink
Merge pull request kodadot#9787 from kodadot/fix-genart-carousel
Browse files Browse the repository at this point in the history
fix: genart carousel
  • Loading branch information
yangwao authored Mar 17, 2024
2 parents 773bd24 + a0c9142 commit bc15017
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
44 changes: 32 additions & 12 deletions components/carousel/utils/useCarouselEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -182,7 +183,7 @@ const GENERATIVE_CONFIG: Partial<
> = {
ahp: {
limit: 12,
collections: AHP_GENERATIVE_DROPS,
collections: [],
},
ahk: {
limit: 3,
Expand All @@ -193,21 +194,40 @@ const GENERATIVE_CONFIG: Partial<
export const useCarouselGenerativeNftEvents = () => {
const nfts = ref<CarouselNFT[]>([])
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 (isProduction && chain === 'ahk') {
return []
}

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
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)
Expand Down
4 changes: 1 addition & 3 deletions utils/drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const AHK_GENERATIVE_DROPS = [
'176', // Chained
]

export const AHP_GENERATIVE_DROPS = [
export const AHP_POPULAR_DROP_COLLECTIONS = [
'112', // Convergente
'108', // Motifs
'106', // Refraction
Expand All @@ -43,8 +43,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 DROP_CARD_MIN_WIDTH = 334 // px

0 comments on commit bc15017

Please sign in to comment.