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: render new Homeview for artsy people #10851

Merged
merged 1 commit into from
Sep 26, 2024
Merged
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
6 changes: 2 additions & 4 deletions src/app/AppRegistry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
WorksForYouScreenQuery,
} from "app/Components/Containers/WorksForYou"
import { FadeIn } from "app/Components/FadeIn"
import { ArtsyNativeModule } from "app/NativeModules/ArtsyNativeModule"
import { ActivityItemScreenQueryRenderer } from "app/Scenes/Activity/ActivityItemScreen"
import { ArtQuiz } from "app/Scenes/ArtQuiz/ArtQuiz"
import { ArtQuizResults } from "app/Scenes/ArtQuiz/ArtQuizResults/ArtQuizResults"
Expand Down Expand Up @@ -143,7 +142,7 @@ import {
ViewingRoomsListScreen,
viewingRoomsListScreenQuery,
} from "./Scenes/ViewingRoom/ViewingRoomsList"
import { GlobalStore, unsafe_getFeatureFlag } from "./store/GlobalStore"
import { GlobalStore } from "./store/GlobalStore"
import { propsStore } from "./store/PropsStore"
import { DevMenu } from "./system/devTools/DevMenu/DevMenu"
import { Schema, screenTrack } from "./utils/track"
Expand Down Expand Up @@ -499,8 +498,7 @@ export const modules = defineModules({
screenOptions: {
statusBarTranslucent: true,
},
fullBleed:
ArtsyNativeModule.isBetaOrDev && !unsafe_getFeatureFlag("ARPreferLegacyHomeScreen"),
fullBleed: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the screens after this change to make sure I didn't break anything

Screen.Recording.2024-09-26.at.17.30.16.mov

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 💯

},
[homeViewScreenQuery]
),
Expand Down
180 changes: 95 additions & 85 deletions src/app/Scenes/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Box,
Flex,
Join,
Screen,
Spacer,
SpacingUnitDSValueNumber,
} from "@artsy/palette-mobile"
Expand Down Expand Up @@ -85,6 +86,7 @@ import {
ViewabilityConfig,
} from "react-native"
import { isTablet } from "react-native-device-info"
import { useSafeAreaInsets } from "react-native-safe-area-context"
import { Environment, RelayRefetchProp, createRefetchContainer, graphql } from "react-relay"
import { useTracking } from "react-tracking"
import { HeroUnitsRail } from "./Components/HeroUnitsRail"
Expand Down Expand Up @@ -134,6 +136,7 @@ const Home = memo((props: HomeProps) => {
useMaybePromptForReview({ contextModule: ContextModule.tabBar, contextOwnerType: OwnerType.home })
const prefetchUrl = usePrefetch()
const tracking = useTracking()
const { top } = useSafeAreaInsets()

const viewabilityConfig = useRef<ViewabilityConfig>({
// Percent of of the item that is visible for a partially occluded item to count as "viewable"
Expand Down Expand Up @@ -353,7 +356,7 @@ const Home = memo((props: HomeProps) => {
)

return (
<View style={{ flex: 1 }}>
<View style={{ flex: 1, paddingTop: top }}>
<AboveTheFoldFlatList<HomeModule>
listRef={flatlistRef}
testID="home-flat-list"
Expand Down Expand Up @@ -634,8 +637,10 @@ const HomePlaceholder: React.FC = () => {
const randomValue = useMemoizedRandom()
const enableLatestActivityRail = useFeatureFlag("AREnableLatestActivityRail")

const { top } = useSafeAreaInsets()

return (
<Flex>
<Flex style={{ paddingTop: top }}>
<Box mb={1} mt={2}>
<Flex alignItems="center">
<ArtsyLogoBlackIcon scale={0.75} />
Expand Down Expand Up @@ -764,89 +769,94 @@ export const HomeQueryRenderer: React.FC<HomeQRProps> = ({ environment }) => {
}, [flash_message])

return (
<AboveTheFoldQueryRenderer<HomeAboveTheFoldQuery, HomeBelowTheFoldQuery>
environment={environment || getRelayEnvironment()}
above={{
query: graphql`
query HomeAboveTheFoldQuery($version: String!) {
homePage @optionalField {
...Home_homePageAbove
}
me @optionalField {
...Home_meAbove
}
newWorksForYou: viewer @optionalField {
...Home_newWorksForYou
}
notificationsConnection: viewer @optionalField {
...Home_notificationsConnection
}
viewer {
...Home_heroUnits
}
}
`,
variables: {
version: worksForYouRecommendationsModel.payload || DEFAULT_RECS_MODEL_VERSION,
},
}}
below={{
query: graphql`
query HomeBelowTheFoldQuery {
homePage @optionalField {
...Home_homePageBelow
}
emergingPicks: marketingCollection(slug: "curators-picks-emerging") @optionalField {
...Home_emergingPicks
}
featured: viewingRoomsConnection(featured: true) @optionalField {
...Home_featured
}
me @optionalField {
...Home_meBelow
...RecommendedArtistsRail_me
}
articlesConnection(first: 10, sort: PUBLISHED_AT_DESC, featured: true) @optionalField {
...Home_articlesConnection
}
news: viewer @optionalField {
...Home_news
}
recommendedAuctionLots: viewer @optionalField {
...Home_recommendedAuctionLots
}
}
`,
variables: {},
}}
render={{
renderComponent: ({ above, below }) => {
if (!above) {
throw new Error("no data")
}
<Screen safeArea={false}>
<Screen.Body fullwidth>
<AboveTheFoldQueryRenderer<HomeAboveTheFoldQuery, HomeBelowTheFoldQuery>
environment={environment || getRelayEnvironment()}
above={{
query: graphql`
query HomeAboveTheFoldQuery($version: String!) {
homePage @optionalField {
...Home_homePageAbove
}
me @optionalField {
...Home_meAbove
}
newWorksForYou: viewer @optionalField {
...Home_newWorksForYou
}
notificationsConnection: viewer @optionalField {
...Home_notificationsConnection
}
viewer {
...Home_heroUnits
}
}
`,
variables: {
version: worksForYouRecommendationsModel.payload || DEFAULT_RECS_MODEL_VERSION,
},
}}
below={{
query: graphql`
query HomeBelowTheFoldQuery {
homePage @optionalField {
...Home_homePageBelow
}
emergingPicks: marketingCollection(slug: "curators-picks-emerging") @optionalField {
...Home_emergingPicks
}
featured: viewingRoomsConnection(featured: true) @optionalField {
...Home_featured
}
me @optionalField {
...Home_meBelow
...RecommendedArtistsRail_me
}
articlesConnection(first: 10, sort: PUBLISHED_AT_DESC, featured: true)
@optionalField {
...Home_articlesConnection
}
news: viewer @optionalField {
...Home_news
}
recommendedAuctionLots: viewer @optionalField {
...Home_recommendedAuctionLots
}
}
`,
variables: {},
}}
render={{
renderComponent: ({ above, below }) => {
if (!above) {
throw new Error("no data")
}

return (
<HomeFragmentContainer
articlesConnection={below?.articlesConnection ?? null}
news={below?.news ?? null}
emergingPicks={below?.emergingPicks ?? null}
featured={below ? below.featured : null}
homePageAbove={above.homePage}
homePageBelow={below ? below.homePage : null}
newWorksForYou={above.newWorksForYou}
notificationsConnection={above.notificationsConnection}
meAbove={above.me}
meBelow={below ? below.me : null}
loading={!below}
heroUnits={above ? above.viewer : null}
recommendedAuctionLots={below?.recommendedAuctionLots ?? null}
/>
)
},
renderPlaceholder: () => <HomePlaceholder />,
}}
cacheConfig={{ force: true }}
belowTheFoldTimeout={100}
/>
return (
<HomeFragmentContainer
articlesConnection={below?.articlesConnection ?? null}
news={below?.news ?? null}
emergingPicks={below?.emergingPicks ?? null}
featured={below ? below.featured : null}
homePageAbove={above.homePage}
homePageBelow={below ? below.homePage : null}
newWorksForYou={above.newWorksForYou}
notificationsConnection={above.notificationsConnection}
meAbove={above.me}
meBelow={below ? below.me : null}
loading={!below}
heroUnits={above ? above.viewer : null}
recommendedAuctionLots={below?.recommendedAuctionLots ?? null}
/>
)
},
renderPlaceholder: () => <HomePlaceholder />,
}}
cacheConfig={{ force: true }}
belowTheFoldTimeout={100}
/>
</Screen.Body>
</Screen>
)
}
17 changes: 17 additions & 0 deletions src/app/Scenes/Home/HomeContainer.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,21 @@ describe("conditional rendering of old vs new home screen", () => {
})
})
})

describe("when using an artsymail account", () => {
beforeEach(() => {
__globalStoreTestUtils__?.injectFeatureFlags({ ARPreferLegacyHomeScreen: false })
})

it("renders the NEW screen", () => {
__globalStoreTestUtils__?.injectState({
auth: {
userEmail: "test@artsymail.com",
},
})

renderWithWrappers(<HomeContainer />)
expect(screen.getByTestId("new-home-view-skeleton")).toBeOnTheScreen()
})
})
})
4 changes: 3 additions & 1 deletion src/app/Scenes/Home/HomeContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export const InnerHomeContainer = () => {
const showPlayground = useDevToggle("DTShowPlayground")

const preferLegacyHomeScreen = useFeatureFlag("ARPreferLegacyHomeScreen")
const isArtsyEmployee = GlobalStore.useAppState((state) => state.auth.userHasArtsyEmail)

const shouldDisplayNewHomeView = ArtsyNativeModule.isBetaOrDev && !preferLegacyHomeScreen
const shouldDisplayNewHomeView =
(isArtsyEmployee || ArtsyNativeModule.isBetaOrDev) && !preferLegacyHomeScreen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to keep the old logic + the condition of having an artsymail account account

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 👍🏼

Copy link
Member

@anandaroop anandaroop Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this check is now out of sync with this one, which was added previously in #10808

const preferLegacyHomeScreen = useFeatureFlag("ARPreferLegacyHomeScreen")
const shouldDisplayNewHomeView = ArtsyNativeModule.isBetaOrDev && !preferLegacyHomeScreen

Any cause for concern? I.e. will Artsy users on the app store versions miss out on any pre-fetching?


const navigateToArtQuiz = async () => {
await navigate("/art-quiz")
Expand Down