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: Replace Touchable with Routerlink for prefetching on artwork and artist rails #11383

Merged
merged 8 commits into from
Jan 15, 2025

Conversation

olerichter00
Copy link
Contributor

@olerichter00 olerichter00 commented Jan 13, 2025

This PR resolves ONYX-1461

Description

This PR replaces Touchable with Routerlink 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 to routes.ts. All updates are explained in the comments.

PR Checklist

  • I have tested my changes on iOS and Android.
  • I hid my changes behind a feature flag, or they don't need one.
  • I have included screenshots or videos, or I have not changed the UI.
  • I have added tests, or my changes don't require any.
  • I added an app state migration, or my changes do not require one.
  • I have documented any follow-up work that this PR will require, or it does not require any.
  • I have added a changelog entry below, or my changes do not require one.

To the reviewers 👀

  • I would like at least one of the reviewers to run this PR on the simulator or device.
Changelog updates

Changelog updates

Cross-platform user-facing changes

  • Replace Touchable with Routerlink for prefetching on artwork and artist rails, as well as some additional rails on the home screen - ole

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.

@olerichter00 olerichter00 self-assigned this Jan 13, 2025
@olerichter00 olerichter00 marked this pull request as draft January 13, 2025 14:32
Comment on lines 199 to 200
queries?: GraphQLTaggedNode[]
queryVariables?: object[]
Copy link
Contributor Author

@olerichter00 olerichter00 Jan 14, 2025

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).

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

good idea

Copy link
Member

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]

Copy link
Contributor Author

@olerichter00 olerichter00 Jan 15, 2025

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.

Copy link
Contributor Author

@olerichter00 olerichter00 Jan 15, 2025

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

Copy link
Member

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

Copy link
Contributor Author

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. 👍

@olerichter00 olerichter00 changed the title feat: Prefetch home screen links feat: Replace Touchable with Routerlink for prefetching on artwork and artist rails Jan 14, 2025
@@ -36,6 +36,7 @@ export const ViewingRoomArtworkRail: React.FC<ViewingRoomArtworkRailProps> = ({
</Flex>
<ArtworkRail
artworks={artworks}
itemHref={(artwork) => `/viewing-room/${viewingRoom.slug}/${artwork.slug}`}
Copy link
Contributor Author

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.

MounirDhahri
MounirDhahri previously approved these changes Jan 14, 2025
Copy link
Member

@MounirDhahri MounirDhahri left a 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/utils/loggers.ts Outdated Show resolved Hide resolved
Comment on lines 199 to 200
queries?: GraphQLTaggedNode[]
queryVariables?: object[]
Copy link
Member

Choose a reason for hiding this comment

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

good idea

Comment on lines 199 to 200
queries?: GraphQLTaggedNode[]
queryVariables?: object[]
Copy link
Member

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]

@olerichter00 olerichter00 marked this pull request as ready for review January 15, 2025 09:06
@olerichter00 olerichter00 force-pushed the olerichter00/ONYX-1461/prefetch-home-screen-links branch from 258f885 to 9e24362 Compare January 15, 2025 09:07
@ArtsyOpenSource
Copy link
Contributor

ArtsyOpenSource commented Jan 15, 2025

This PR contains the following changes:

  • Cross-platform user-facing changes (Replace Touchable with Routerlink for prefetching on artwork and artist rails, as well as some additional rails on the home screen - ole - olerichter00)

Generated by 🚫 dangerJS against d53dd73

@olerichter00 olerichter00 merged commit aa6c47d into main Jan 15, 2025
7 checks passed
@olerichter00 olerichter00 deleted the olerichter00/ONYX-1461/prefetch-home-screen-links branch January 15, 2025 12:41
@@ -336,7 +347,8 @@ export const artsyDotNetRoutes = defineRoutes([
headerShown: false,
},
},
Queries: [ArtistScreenQuery],
queries: [ArtistScreenQuery],
queryVariables: [defaultArtistVariables],
Copy link
Member

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants