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: add home view section screen #10546

Merged
merged 20 commits into from
Sep 11, 2024
Merged

Conversation

MounirDhahri
Copy link
Member

@MounirDhahri MounirDhahri commented Aug 1, 2024

[Ready for view as of Monday 9th, September]

This PR resolves ONYX-1159

Description

This PR adds a new screen generic type that will render a list of artworks.

Screen.Recording.2024-09-09.at.12.07.53.mov
Screen.Recording.2024-09-09.at.15.44.06.mov

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

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.

@MounirDhahri MounirDhahri self-assigned this Aug 1, 2024
@ArtsyOpenSource
Copy link
Contributor

ArtsyOpenSource commented Aug 1, 2024

Warnings
⚠️

An error occurred while validating your changelog, please make sure you provided a valid changelog.

Generated by 🚫 dangerJS against 76f9ea2

@@ -192,6 +192,7 @@ function getDomainMap(): Record<string, RouteMatcher[] | null> {
addRoute("/galleries-for-you", "GalleriesForYou"),
addRoute("/gene/:geneID", "Gene"),
addRoute("/home-view", "HomeView"),
addRoute("/home-view/section/:sectionId", "HomeSectionScreen"),
Copy link
Member Author

Choose a reason for hiding this comment

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

glad to hear thoughts about the naming here

Copy link
Member

Choose a reason for hiding this comment

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

suggestion: sectionId > sectionID

Copy link
Member Author

Choose a reason for hiding this comment

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

nice idea

@MounirDhahri MounirDhahri marked this pull request as ready for review August 2, 2024 12:58
artworksQuery,
{ id: props.sectionId },
{
// This is necessary to avoid displaying cached because this component is used in more than one place and Relay returns data from another screen before the new data is loaded.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this return cached data per sectionID? 🤔


// This won't happen because the query would fail thanks to the @principalField
// Adding it here to make TS happy
if (!data.homeView.section || !data.homeView.section.component?.title) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we require the title here, should we make it nonNullable in the schema instead?

Copy link
Member

Choose a reason for hiding this comment

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

I believe title was already non-nullable but this PR should alleviate the other null checking here.

Copy link
Member

@dblandin dblandin left a comment

Choose a reason for hiding this comment

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

Looking good! 🔥

// This is necessary to avoid displaying cached because this component is used in more than one place and Relay returns data from another screen before the new data is loaded.
fetchPolicy: "network-only",
}
)
Copy link
Member

Choose a reason for hiding this comment

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

question: Curious is there's a way to prevent relay cache data from leaking into the wrong components. I would think that maybe the arguments, like ID, would determine if a cached result is eligible or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree- maybe this is something to look into- tbh it wasn't an issue when I built this. I mainly copied the code here but probably it's not needed anymore https://github.com/artsy/eigen/blob/70571f97c97fb86cd8f0e997496107e33602f693/src/app/Components/WorksForYouArtworks.tsx#L126

}

export const ArtworksScreenHomeSection: React.FC<ArtworksScreenHomeSection> = ({ section }) => {
const defaultViewOption = GlobalStore.useAppState((state) => state.userPrefs.defaultViewOption)
Copy link
Member

Choose a reason for hiding this comment

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

question: Without having a control to toggle between the two options, should we explicitly pick a view style rather than referring to this default?


// This won't happen because the query would fail thanks to the @principalField
// Adding it here to make TS happy
if (!data.homeView.section || !data.homeView.section.component?.title) {
Copy link
Member

Choose a reason for hiding this comment

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

I believe title was already non-nullable but this PR should alleviate the other null checking here.

@MounirDhahri MounirDhahri force-pushed the feat/add-home-view-section-screen branch from db88378 to 880220a Compare August 6, 2024 13:30
Copy link
Member

@anandaroop anandaroop left a comment

Choose a reason for hiding this comment

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

Looks good! Just one question below

@@ -192,6 +192,7 @@ function getDomainMap(): Record<string, RouteMatcher[] | null> {
addRoute("/galleries-for-you", "GalleriesForYou"),
addRoute("/gene/:geneID", "Gene"),
addRoute("/home-view", "HomeView"),
addRoute("/home-view/sections/:sectionID", "HomeViewSectionScreen"),
Copy link
Member

Choose a reason for hiding this comment

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

thought (non-blocking): Skimming the route list it occurs to me that there isn't really a good way of telling which routes are dev-only (L194) or Eigen-only (L194–195). The vast majority of these routes are also valid public routes on web, but not all. I wonder if we'd consider some added structure to this list 🤔 (but not for this PR).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's in the pipeline for next quarter with Sapphire. We are thinking of adjusting this file and making things easier here

@@ -22,7 +22,7 @@ export const ArtworksRailHomeViewSection: React.FC<ArtworksRailHomeViewSectionPr
const data = useFragment(fragment, section)
const title = data.component?.title
const artworks = extractNodes(data.artworksConnection)
const componentHref = data.component?.behaviors?.viewAll?.href
const componentHref = "home-view/sections/" + data.internalID
Copy link
Member

Choose a reason for hiding this comment

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

question: Shouldn't this prefer to navigate to the viewAll.href if it is provided, and only provide the generic full-screen experience here if viewAll.href is falsy?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think we were agreeing on this behavior (response 2): artsy/metaphysics#5963 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point - I will the MP changes to reflect that the default behaviour is what we need here.

Copy link
Member Author

Choose a reason for hiding this comment

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

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 made some changes here and added a new helper for future use
Screenshot 2024-09-10 at 11 27 23

@MounirDhahri MounirDhahri force-pushed the feat/add-home-view-section-screen branch from 3673518 to 76f9ea2 Compare September 10, 2024 12:48
@MounirDhahri
Copy link
Member Author

Lol I messed up git history 😄 - sorry for the many commits

@MounirDhahri
Copy link
Member Author

Going to merge this PR before I need to merge conflicts from 10 commits - I addressed all review comments above and will be glad to address any others that come up

@MounirDhahri MounirDhahri merged commit b0bea32 into main Sep 11, 2024
7 checks passed
@MounirDhahri MounirDhahri deleted the feat/add-home-view-section-screen branch September 11, 2024 06:58
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.

6 participants