Skip to content

Commit

Permalink
chore: use contextModule
Browse files Browse the repository at this point in the history
  • Loading branch information
MounirDhahri committed Sep 20, 2024
1 parent 3f7c07c commit 06b10cc
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions src/app/Scenes/HomeView/Components/HomeViewSectionWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ import React, { useCallback } from "react"

interface HomeViewSectionWrapperProps {
children: React.ReactNode
sectionID?: string
contextModule?: ContextModule
}

export const HomeViewSectionWrapper: React.FC<HomeViewSectionWrapperProps> = ({
children,
sectionID,
contextModule,
}) => {
const { viewedSection } = useHomeViewTracking()
const addTrackedSection = HomeViewStore.useStoreActions((actions) => actions.addTrackedSection)
const trackedSections = HomeViewStore.useStoreState((state) => state.trackedSections)

const handleImageVisibility = useCallback(() => {
if (sectionID && !trackedSections.includes(sectionID)) {
viewedSection(sectionID as ContextModule)
addTrackedSection(sectionID)
if (contextModule && !trackedSections.includes(contextModule)) {
viewedSection(contextModule as ContextModule)
addTrackedSection(contextModule)
}
}, [sectionID, viewedSection, addTrackedSection, trackedSections])
}, [contextModule, viewedSection, addTrackedSection, trackedSections])

// We only track section views if we have a sectionID
if (sectionID) {
// We only track section views if we have a contextModule
if (contextModule) {
return (
<VisibilitySensor onChange={handleImageVisibility}>
<Flex my={HOME_VIEW_SECTIONS_SEPARATOR_HEIGHT}>{children}</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const HomeViewSectionActivity: React.FC<HomeViewSectionActivityProps> = (
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<Flex px={2}>
<SectionTitle title={section.component?.title} onPress={onSectionViewAll} />
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const HomeViewSectionArticles: React.FC<HomeViewSectionArticlesProps> = (
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<ArticlesRailFragmentContainer
title={section.component?.title ?? ""}
articlesConnection={section.articlesConnection}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const HomeViewSectionArticlesCards: React.FC<HomeViewSectionArticlesCards
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<Flex mx={2} p={2} border="1px solid" borderColor="black30" gap={space(2)}>
<Flex flexDirection="row" justifyContent="space-between" alignItems="center">
<Text variant="lg-display">{section.component?.title}</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const HomeViewSectionArtists: React.FC<HomeViewSectionArtworksProps> = ({
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<Flex px={2}>
<SectionTitle
title={section.component?.title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const HomeViewSectionArtworks: React.FC<HomeViewSectionArtworksProps> = (
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<View>
<Flex pl={2} pr={2}>
<SectionTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const HomeViewSectionAuctionResults: React.FC<HomeViewSectionAuctionResul
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<Flex px={2}>
<SectionTitle
title={section.component?.title ?? "Auction Results"}
Expand Down
2 changes: 1 addition & 1 deletion src/app/Scenes/HomeView/Sections/HomeViewSectionFairs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const HomeViewSectionFairs: React.FC<HomeViewSectionFairsProps> = (props)
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<Flex pl={2} pr={2}>
<SectionTitle
title={section.component?.title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const HomeViewSectionFeaturedCollection: React.FC<HomeViewSectionFeatured
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<Flex pb={2} backgroundColor="black100">
<TouchableOpacity onPress={onSectionViewAll} activeOpacity={0.7}>
{!!component.backgroundImageURL && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const HomeViewSectionGalleries: React.FC<HomeViewSectionGalleriesProps> =
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<Touchable onPress={onSectionViewAll} haptic="impactLight">
{!!hasImage && (
<Flex position="absolute">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const HomeViewSectionHeroUnits: React.FC<HomeViewSectionHeroUnitsProps> =
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<FlatList
data={heroUnits}
decelerationRate="fast"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const HomeViewSectionMarketingCollections: React.FC<
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<Flex pl={2} pr={2}>
<SectionTitle title={component.title} onPress={viewAll ? onSectionViewAll : undefined} />
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion src/app/Scenes/HomeView/Sections/HomeViewSectionSales.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const HomeViewSectionSales: React.FC<HomeViewSectionSalesProps> = (props)
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<Flex px={2}>
<SectionTitle
title={section.component?.title}
Expand Down
2 changes: 1 addition & 1 deletion src/app/Scenes/HomeView/Sections/HomeViewSectionShows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const HomeViewSectionShows: React.FC<HomeViewSectionShowsProps> = (props)
const tracking = useHomeViewTracking()

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<ShowsRailContainer
title={component?.title || "Shows"}
disableLocation={!enableShowsForYouLocation}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const HomeViewSectionViewingRooms: React.FC<{
}

return (
<HomeViewSectionWrapper sectionID={section.internalID}>
<HomeViewSectionWrapper contextModule={section.contextModule as ContextModule}>
<Flex px={2}>
<SectionTitle
title={section.component?.title}
Expand Down

0 comments on commit 06b10cc

Please sign in to comment.