diff --git a/packages/web/src/pages/search-explore-page/components/desktop/FeaturedRemixContestsSection.tsx b/packages/web/src/pages/search-explore-page/components/desktop/FeaturedRemixContestsSection.tsx index 1466cbd0624..20444134b71 100644 --- a/packages/web/src/pages/search-explore-page/components/desktop/FeaturedRemixContestsSection.tsx +++ b/packages/web/src/pages/search-explore-page/components/desktop/FeaturedRemixContestsSection.tsx @@ -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' @@ -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') @@ -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 }