Skip to content

Commit

Permalink
chore: remove last named inline spread from top-level home view query
Browse files Browse the repository at this point in the history
Since switching sectionsConnection to be backed by an interface rather than a
union, we can query for those standard attributes without the named inline
spread.
  • Loading branch information
dblandin committed Sep 17, 2024
1 parent 550fabf commit 88b339c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
13 changes: 6 additions & 7 deletions src/app/Scenes/HomeView/HomeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const HomeView: React.FC = () => {
<FlashList
ref={flashlistRef}
data={sections}
keyExtractor={(item) => `${item.internalID || ""}`}
keyExtractor={(item) => item.internalID}
renderItem={({ item }) => {
return <Section section={item} />
}}
Expand Down Expand Up @@ -151,13 +151,12 @@ const sectionsFragment = graphql`
edges {
node {
__typename
... on HomeViewSectionGeneric {
internalID
component {
type
}
...HomeViewSectionGeneric_section
internalID
component {
title
type
}
...HomeViewSectionGeneric_section
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/Scenes/HomeView/Sections/HomeViewSectionGeneric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ export const HomeViewSectionGeneric: React.FC<{ section: any }> = (props) => {

const genericSectionFragment = graphql`
fragment HomeViewSectionGeneric_section on HomeViewSectionGeneric {
__typename
internalID
component {
title
type
}
}
`
14 changes: 5 additions & 9 deletions src/app/Scenes/HomeView/Sections/Section.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Flex, Text } from "@artsy/palette-mobile"
import { HomeViewSectionsConnection_viewer$data } from "__generated__/HomeViewSectionsConnection_viewer.graphql"
import { HomeViewSectionGeneric_section$data } from "__generated__/HomeViewSectionGeneric_section.graphql"
import { HomeViewSectionActivityQueryRenderer } from "app/Scenes/HomeView/Sections/HomeViewSectionActivity"
import { HomeViewSectionArticlesQueryRenderer } from "app/Scenes/HomeView/Sections/HomeViewSectionArticles"
import { HomeViewSectionArticlesCardsQueryRenderer } from "app/Scenes/HomeView/Sections/HomeViewSectionArticlesCards"
Expand All @@ -15,15 +15,11 @@ import { HomeViewSectionMarketingCollectionsQueryRenderer } from "app/Scenes/Hom
import { HomeViewSectionSalesQueryRenderer } from "app/Scenes/HomeView/Sections/HomeViewSectionSales"
import { HomeViewSectionShowsQueryRenderer } from "app/Scenes/HomeView/Sections/HomeViewSectionShows"
import { HomeViewSectionViewingRoomsQueryRenderer } from "app/Scenes/HomeView/Sections/HomeViewSectionViewingRooms"
import { ExtractNodeType } from "app/utils/relayHelpers"
import { CleanRelayFragment } from "app/utils/relayHelpers"

type SectionsConnection = NonNullable<
HomeViewSectionsConnection_viewer$data["homeView"]["sectionsConnection"]
>

type SectionT = ExtractNodeType<SectionsConnection>

export const Section: React.FC<{ section: SectionT }> = (props) => {
export const Section: React.FC<{
section: CleanRelayFragment<HomeViewSectionGeneric_section$data>
}> = (props) => {
const { section } = props

if (!section.internalID) {
Expand Down
13 changes: 5 additions & 8 deletions src/app/Scenes/HomeViewSectionScreen/HomeViewSectionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@ const HOME_SECTION_SCREEN_QUERY = graphql`
homeView {
section(id: $id) {
__typename
... on HomeViewSectionGeneric {
component {
title
}
internalID
component {
title
}
... on HomeViewSectionArtworks {
internalID
component {
title
}
...HomeViewSectionScreenArtworks_section
}
}
Expand Down

0 comments on commit 88b339c

Please sign in to comment.