Skip to content

Commit

Permalink
Revert "fix: Preload Shows for You rail" (#9147)
Browse files Browse the repository at this point in the history
Revert "fix: Preload Shows for You rail (#9064)"

This reverts commit 0952ea7.
  • Loading branch information
olerichter00 authored and gkartalis committed Aug 9, 2023
1 parent 93f31b8 commit cc24281
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 29 deletions.
28 changes: 4 additions & 24 deletions src/app/Scenes/Home/Components/ShowsRail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import { extractNodes } from "app/utils/extractNodes"
import { useDevToggle } from "app/utils/hooks/useDevToggle"
import { Location, useLocation } from "app/utils/hooks/useLocation"
import { PlaceholderBox, RandomWidthPlaceholderText } from "app/utils/placeholders"
import { prefetchQuery } from "app/utils/queryPrefetching"
import { times } from "lodash"
import { Suspense, memo, useEffect } from "react"
import { Suspense, memo } from "react"
import { FlatList } from "react-native"
import { graphql, useFragment, useLazyLoadQuery } from "react-relay"
import { useTracking } from "react-tracking"
Expand All @@ -27,7 +26,9 @@ const NUMBER_OF_SHOWS = 10
export const ShowsRail: React.FC<ShowsRailProps> = memo(({ disableLocation, location, title }) => {
const tracking = useTracking()

const queryVariables = getQueryVariables(location, disableLocation)
const queryVariables = location
? { near: location }
: { includeShowsNearIpBasedLocation: !disableLocation && !location }

const queryData = useLazyLoadQuery<ShowsRailQuery>(ShowsQuery, queryVariables)

Expand Down Expand Up @@ -166,24 +167,3 @@ const ShowsRailPlaceholder: React.FC = () => {
</Flex>
)
}

const getQueryVariables = (location: Location | null | undefined, disableLocation: boolean) => {
return location
? { near: location }
: { includeShowsNearIpBasedLocation: !disableLocation && !location }
}

export const usePreloadShowsRail = (disableLocation: boolean) => {
const { location, isLoading } = useLocation({
disabled: disableLocation,
skipPermissionRequests: true,
})

useEffect(() => {
if (!isLoading) {
return
}

prefetchQuery(ShowsQuery, getQueryVariables(location, disableLocation))
}, [isLoading])
}
5 changes: 1 addition & 4 deletions src/app/Scenes/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { MeetYourNewAdvisorRail } from "app/Scenes/Home/Components/MeetYourNewAd
import { NewWorksForYouRail } from "app/Scenes/Home/Components/NewWorksForYouRail"
import { OldCollectionsRailFragmentContainer } from "app/Scenes/Home/Components/OldCollectionsRail"
import { SalesRailFragmentContainer } from "app/Scenes/Home/Components/SalesRail"
import { ShowsRailContainer, usePreloadShowsRail } from "app/Scenes/Home/Components/ShowsRail"
import { ShowsRailContainer } from "app/Scenes/Home/Components/ShowsRail"
import { RailScrollRef } from "app/Scenes/Home/Components/types"
import {
DEFAULT_RECS_MODEL_VERSION,
Expand Down Expand Up @@ -177,9 +177,6 @@ const Home = memo((props: HomeProps) => {
"CX-impressions-tracking-home-rail-views"
)

// Preloading the Shows for You rail to avoid loading it when the user scrolls. This is needed because it has it's own query renderer.
usePreloadShowsRail(enableShowsForYouLocation)

// Make sure to include enough modules in the above-the-fold query to cover the whole screen!.
const { modules, allModulesKeys } = useHomeModules(props)

Expand Down
2 changes: 1 addition & 1 deletion src/app/utils/queryPrefetching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function isRateLimited() {
return remainingRequests < 0
}

export const prefetchQuery = async (query: GraphQLTaggedNode, variables?: Variables) => {
const prefetchQuery = async (query: GraphQLTaggedNode, variables?: Variables) => {
const environment = getRelayEnvironment()
const operation = createOperationDescriptor(getRequest(query), variables ?? {})

Expand Down

0 comments on commit cc24281

Please sign in to comment.