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: Prefetch all links as they enter the viewport #11293

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

olerichter00
Copy link
Contributor

@olerichter00 olerichter00 commented Dec 17, 2024

This PR resolves ONYX-1461

Description

This is an effort to prefetch all links as they enter the viewport.

This PR introduces a RouterLink component that wraps Palette's Touchable and takes an extra to prop with a URL or path to link to. If prefetching is enabled, the component automatically prefetches the URL or path as soon as it enters the viewport.

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

  • Prefetch links as they enter the viewport - 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 marked this pull request as draft December 17, 2024 14:44
@olerichter00 olerichter00 self-assigned this Dec 17, 2024
@@ -26,12 +26,12 @@ import { ContextMenuArtwork } from "app/Components/ContextMenu/ContextMenuArtwor
import { DurationProvider } from "app/Components/Countdown"
import { Disappearable, DissapearableArtwork } from "app/Components/Disappearable"
import { ProgressiveOnboardingSaveArtwork } from "app/Components/ProgressiveOnboarding/ProgressiveOnboardingSaveArtwork"
import { RouterLink } from "app/Components/RouterLink"
Copy link
Member

Choose a reason for hiding this comment

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

Can we place all system-level things in the System folder? https://github.com/artsy/eigen/tree/main/src/app/system/navigation

(in general, we should leverage this folder more for framework-y things -- cc @MounirDhahri)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I'll move the component to the systems folder 👍


return (
<ElementInView onVisible={handleVisible}>
<Touchable {...restProps} onPress={handlePress} />
Copy link
Member

Choose a reason for hiding this comment

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

I wonder here if Touchable would be our preferred way, sometimes we use TouchableOpacity and sometimes we use TouchableWithoutHighlight.
Anyway, that's a problem for later, we can start with this now and extend it later.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe this is a call to use RouterTouchableOpacity 🤷

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 used the Touchable component from "@artsy/palette-mobile" and figured this is probably the preferred one. It has a prop to adjust the opacity on press.

Yeah, RouterTouchableOpacity or RouterTouchable could also be good names for this component. I took the name RouterLink from Force but haven't thought much about naming yet. I'm very open for ideas for the naming.

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.

3 participants