-
Notifications
You must be signed in to change notification settings - Fork 584
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: Replace Touchable with Routerlink for prefetching on artwork and artist rails #11383
feat: Replace Touchable with Routerlink for prefetching on artwork and artist rails #11383
Conversation
src/app/Navigation/routes.tsx
Outdated
queries?: GraphQLTaggedNode[] | ||
queryVariables?: object[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming Queries
to queries
and adding queryVariables
to enable defining default variables for each query (e.g., for sorting or default filters). This is important to prefetch queries with the exact same variables as the screen (so far this is only needed for the Artist screen).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will have a look to see if we can specify the default variables within the query instead. This should work in most cases and would be cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion:
How about we combine the queries
and queryVariables
at a single variable to avoid having to match two arrays.
queries: [{name: Screen1Query}, {name: Screen2Query, variables: Screen2Variables }]
instead of
queries: [Screen1Query, Screen2Query]
querVariables: [null, Screen2Variables]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very good idea. The reason I went with the "simpler" solution is that adding querVariables
is quite an edge case (only one case so far), and I wanted to keep the route definition as concise as possible. I know it's not very clean, but in almost all cases, it will look like
queries: [Screen1Query, Screen2Query]
instead of (query
instead of name
because we're defining the query itself).
queries: [{ query: Screen1Query }, { query: Screen2Query }]
Please let me know what you think. I would also be okay with your solution and my urge to keep it concise might not be the best idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added comments to the new route attributes in d53dd73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me - let's keep an eye on the API here in case more stuff gets added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if we need to add more defaultVariables
in the future or more values, the object should be updated. 👍
@@ -36,6 +36,7 @@ export const ViewingRoomArtworkRail: React.FC<ViewingRoomArtworkRailProps> = ({ | |||
</Flex> | |||
<ArtworkRail | |||
artworks={artworks} | |||
itemHref={(artwork) => `/viewing-room/${viewingRoom.slug}/${artwork.slug}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The viewing room artwork rail links to the viewing room artwork screen instead of the artwork screen and uses the itemHref
prop to customize the linking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I left a small comment about routes.ts
for a code preference. It's not blocking though
src/app/Navigation/routes.tsx
Outdated
queries?: GraphQLTaggedNode[] | ||
queryVariables?: object[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
src/app/Navigation/routes.tsx
Outdated
queries?: GraphQLTaggedNode[] | ||
queryVariables?: object[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion:
How about we combine the queries
and queryVariables
at a single variable to avoid having to match two arrays.
queries: [{name: Screen1Query}, {name: Screen2Query, variables: Screen2Variables }]
instead of
queries: [Screen1Query, Screen2Query]
querVariables: [null, Screen2Variables]
258f885
to
9e24362
Compare
@@ -336,7 +347,8 @@ export const artsyDotNetRoutes = defineRoutes([ | |||
headerShown: false, | |||
}, | |||
}, | |||
Queries: [ArtistScreenQuery], | |||
queries: [ArtistScreenQuery], | |||
queryVariables: [defaultArtistVariables], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR resolves ONYX-1461
Description
This PR replaces
Touchable
withRouterlink
for prefetching on artwork and artist rails, as well as some additional rails on the home screen. It also makes some changes to the RouterLink component and toroutes.ts
. All updates are explained in the comments.PR Checklist
To the reviewers 👀
Changelog updates
Changelog updates
Cross-platform user-facing changes
iOS user-facing changes
Android user-facing changes
Dev changes
Need help with something? Have a look at our docs, or get in touch with us.