Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useExploreContent } from '@audius/common/api'
import { useAllRemixContests, useExploreContent } from '@audius/common/api'
import { exploreMessages as messages } from '@audius/common/messages'
import { route } from '@audius/common/utils'
import { Box } from '@audius/harmony'
Expand All @@ -10,6 +10,11 @@ import { CONTEST_CARD_WIDTH } from './constants'
import { useExploreSectionTracking } from './useExploreSectionTracking'

const SKELETON_COUNT = 6
// Big enough to cover the featured set with headroom — the All Contests
// endpoint primes a per-track entry-count cache as a side-effect (see
// `useAllRemixContests` queryFn). One batched fetch here replaces ~N
// per-card count-only fetches from `useRemixesCount` inside ContestCard.
const PRIME_BATCH_SIZE = 30

export const FeaturedRemixContestsSection = () => {
const { ref, inView } = useExploreSectionTracking('Featured Remix Contests')
Expand All @@ -18,6 +23,12 @@ export const FeaturedRemixContestsSection = () => {
enabled: inView
})

// Side-effect: fetch+prime entry counts for the featured contests so
// ContestCard's `useRemixesCount` hits cache instead of firing a
// count-only request per card. The return value is intentionally
// unused — we only care about the priming inside the hook's queryFn.
useAllRemixContests({ pageSize: PRIME_BATCH_SIZE }, { enabled: inView })

if (isError || (isSuccess && !data?.featuredRemixContests?.length)) {
return null
}
Expand Down
Loading