Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[WIP]: Home view prefetching part II #11414

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions src/app/Scenes/HomeView/Components/ActivityIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { BellIcon, Box, DEFAULT_HIT_SLOP, VisualClueDot } from "@artsy/palette-mobile"
import { useHomeViewTracking } from "app/Scenes/HomeView/hooks/useHomeViewTracking"
import { navigate } from "app/system/navigation/navigate"
import { RouterLink } from "app/system/navigation/RouterLink"
import { useActivityDotExperiment } from "app/utils/experiments/useActivityDotExperiment"
import React from "react"
import { TouchableOpacity } from "react-native"

interface ActivityIndicatorProps {
hasUnseenNotifications: boolean
Expand All @@ -22,19 +21,19 @@ export const ActivityIndicator: React.FC<ActivityIndicatorProps> = (props) => {

const navigateToActivityPanel = () => {
tracking.tappedNotificationBell()

navigate("/notifications")
}

return (
<Box justifyContent="center">
<TouchableOpacity
<RouterLink
accessibilityLabel="Activity"
activeOpacity={0.65}
to="/notifications"
onPress={navigateToActivityPanel}
hitSlop={DEFAULT_HIT_SLOP}
>
<BellVariant hasUnseenNotifications={displayUnseenNotifications} />
</TouchableOpacity>
</RouterLink>
</Box>
)
}
Expand Down
42 changes: 9 additions & 33 deletions src/app/Scenes/HomeView/Components/ActivityRail.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Flex, Spacer, Text, useTheme } from "@artsy/palette-mobile"
import { Flex, Spacer } from "@artsy/palette-mobile"
import { ActivityRail_viewer$key } from "__generated__/ActivityRail_viewer.graphql"
import { SectionTitle } from "app/Components/SectionTitle"
import { shouldDisplayNotification } from "app/Scenes/Activity/utils/shouldDisplayNotification"
import { ActivityRailItem } from "app/Scenes/HomeView/Components/ActivityRailItem"
import { SeeAllCard } from "app/Scenes/HomeView/Components/SeeAllCard"
import HomeAnalytics from "app/Scenes/HomeView/helpers/homeAnalytics"
import { navigate } from "app/system/navigation/navigate"
import { matchRoute } from "app/system/navigation/utils/matchRoute"
import { extractNodes } from "app/utils/extractNodes"
import { FlatList, TouchableOpacity } from "react-native"
import { FlatList } from "react-native"
import { graphql, useFragment } from "react-relay"
import { useTracking } from "react-tracking"

Expand All @@ -16,6 +16,8 @@ interface ActivityRailProps {
viewer: ActivityRail_viewer$key | null
}

const ACTIVITY_SCREEN_ROUTE = "/notifications"

export const ActivityRail: React.FC<ActivityRailProps> = ({ title, viewer }) => {
const { trackEvent } = useTracking()

Expand All @@ -29,25 +31,21 @@ export const ActivityRail: React.FC<ActivityRailProps> = ({ title, viewer }) =>
return null
}

const handleHeaderPress = () => {
trackEvent(HomeAnalytics.activityHeaderTapEvent())
}

const handleMorePress = () => {
trackEvent(HomeAnalytics.activityViewAllTapEvent())

navigate("/notifications")
}

return (
<Flex pt={2}>
<SectionTitle title={title} onPress={handleHeaderPress} href="/notifications" mx={2} />
<SectionTitle title={title} onPress={handleMorePress} href={ACTIVITY_SCREEN_ROUTE} mx={2} />

<FlatList
horizontal
showsHorizontalScrollIndicator={false}
ListHeaderComponent={() => <Spacer x={2} />}
ListFooterComponent={() => <SeeAllCard onPress={handleMorePress} />}
ListFooterComponent={() => (
<SeeAllCard href={ACTIVITY_SCREEN_ROUTE} onPress={handleMorePress} />
)}
ItemSeparatorComponent={() => <Spacer x={2} />}
data={notifications}
keyExtractor={(item) => item.internalID}
Expand Down Expand Up @@ -97,25 +95,3 @@ const notificationsConnectionFragment = graphql`
}
}
`

interface SeeAllCardProps {
onPress: () => void
buttonText?: string | null
}

export const SeeAllCard: React.FC<SeeAllCardProps> = ({ buttonText, onPress }) => {
const { space } = useTheme()

return (
<Flex flex={1} px={1} mx={4} justifyContent="center">
<TouchableOpacity
onPress={onPress}
hitSlop={{ top: space(1), bottom: space(1), left: space(1), right: space(1) }}
>
<Text accessibilityLabel="See All" fontWeight="bold">
{buttonText ?? "See All"}
</Text>
</TouchableOpacity>
</Flex>
)
}
27 changes: 27 additions & 0 deletions src/app/Scenes/HomeView/Components/SeeAllCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Flex, Text, useTheme } from "@artsy/palette-mobile"
import { RouterLink } from "app/system/navigation/RouterLink"

interface SeeAllCardProps {
onPress: () => void
buttonText?: string | null
href: string
}

export const SeeAllCard: React.FC<SeeAllCardProps> = ({ buttonText, href, onPress }) => {
const { space } = useTheme()

return (
<Flex flex={1} px={1} mx={4} justifyContent="center">
<RouterLink
to={href}
activeOpacity={0.65}
onPress={onPress}
hitSlop={{ top: space(1), bottom: space(1), left: space(1), right: space(1) }}
>
<Text accessibilityLabel="See All" fontWeight="bold">
{buttonText ?? "See All"}
</Text>
</RouterLink>
</Flex>
)
}
10 changes: 8 additions & 2 deletions src/app/Scenes/HomeView/Sections/HomeViewSectionActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { HomeViewSectionActivityQuery } from "__generated__/HomeViewSectionActiv
import { HomeViewSectionActivity_section$key } from "__generated__/HomeViewSectionActivity_section.graphql"
import { SectionTitle } from "app/Components/SectionTitle"
import { shouldDisplayNotification } from "app/Scenes/Activity/utils/shouldDisplayNotification"
import { SeeAllCard } from "app/Scenes/HomeView/Components/ActivityRail"
import {
ACTIVITY_RAIL_ARTWORK_IMAGE_SIZE,
ACTIVITY_RAIL_ITEM_WIDTH,
ActivityRailItem,
} from "app/Scenes/HomeView/Components/ActivityRailItem"
import { HomeViewSectionSentinel } from "app/Scenes/HomeView/Components/HomeViewSectionSentinel"
import { SeeAllCard } from "app/Scenes/HomeView/Components/SeeAllCard"
import { SectionSharedProps } from "app/Scenes/HomeView/Sections/Section"
import {
HORIZONTAL_FLATLIST_INTIAL_NUMBER_TO_RENDER_DEFAULT,
Expand Down Expand Up @@ -78,7 +78,13 @@ export const HomeViewSectionActivity: React.FC<HomeViewSectionActivityProps> = (
ListHeaderComponent={() => <Spacer x={2} />}
ListFooterComponent={
viewAll
? () => <SeeAllCard buttonText={viewAll.buttonText} onPress={onSectionViewAll} />
? () => (
<SeeAllCard
href={href}
buttonText={viewAll.buttonText}
onPress={onSectionViewAll}
/>
)
: undefined
}
ItemSeparatorComponent={() => <Spacer x={2} />}
Expand Down
5 changes: 2 additions & 3 deletions src/app/Scenes/HomeView/Sections/HomeViewSectionSales.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ export const HomeViewSectionSales: React.FC<HomeViewSectionSalesProps> = ({

return (
<Flex {...flexProps}>
<Flex px={2}>
<SectionTitle href={href} title={section.component?.title} onPress={onHeaderPress} />
</Flex>
<SectionTitle px={2} href={href} title={section.component?.title} onPress={onHeaderPress} />

<CardRailFlatList
prefetchUrlExtractor={(item) => item?.href}
prefetchVariablesExtractor={(item) => ({ saleSlug: item?.slug })}
Expand Down