-
Notifications
You must be signed in to change notification settings - Fork 592
feat(DIAM-49): collections by filtered artworks #12788
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(DIAM-49): collections by filtered artworks #12788
Conversation
nickskalkin
left a comment
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.
Looks good to me! Also attaching artsy/metaphysics#7054 to give more context for other reviewers
Asking @MounirDhahri to review too since he was working on adding Collect screen
src/app/Scenes/CollectionsByFilter/CollectionsByFilterChips.tsx
Outdated
Show resolved
Hide resolved
src/app/Scenes/CollectionsByFilter/CollectionsByFilterChips.tsx
Outdated
Show resolved
Hide resolved
|
Thanks for the tag @nickskalkin looking into it now |
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.
Pull Request Overview
This PR adds support for collections made by artworks with filters in the Explore By section. The implementation creates a new CollectionsByFilter route that renders artworks with applied filters rather than curated marketing collections, avoiding code complexity in the existing CollectionsByCategory implementation.
- Creates new CollectionsByFilter route and components for filtered artwork collections
- Refactors existing components to support both marketing collections and filtered artworks
- Adds comprehensive test coverage for the new functionality
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/app/Scenes/CollectionsByFilter/* | New components for filtered artwork collections functionality |
| src/app/Scenes/Search/components/ExploreByCategory/ExploreByCategoryCard.tsx | Updated to use dynamic href from GraphQL instead of hardcoded path |
| src/app/Scenes/CollectionsByCategory/hooks/useCollectionsByCategoryParams.ts | Extracted shared route parameter logic for reuse |
| src/app/Scenes/CollectionsByCategory/*.tsx | Refactored to use shared parameter hook and updated component structure |
| src/app/Scenes/Collect/Collect.tsx | Enhanced to support dynamic title/subtitle parameters |
| src/app/Navigation/routes.tsx | Added new CollectionsByFilter route configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/app/Scenes/CollectionsByFilter/CollectionsByFilterListItem.tsx
Outdated
Show resolved
Hide resolved
| const collections = extractNodes(data.chipsFilteredCollections) | ||
|
|
||
| const numRows = !isTablet() ? 3 : 2 | ||
| const numColumns = Math.ceil(collections.length / 3) |
Copilot
AI
Sep 26, 2025
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.
Hard-coded magic number 3 should be replaced with the numRows variable for consistency and maintainability.
| const numColumns = Math.ceil(collections.length / 3) | |
| const numColumns = Math.ceil(collections.length / numRows) |
| return ( | ||
| <> | ||
| <Separator borderColor="mono10" mt={4} /> | ||
| {Array.from({ length: total - filtersForArtworksConnection.length }).map((_, i) => ( |
Copilot
AI
Sep 26, 2025
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 calculation can result in a negative length if filtersForArtworksConnection.length exceeds total, which would cause an error. Add a Math.max(0, ...) wrapper to prevent negative values.
| {Array.from({ length: total - filtersForArtworksConnection.length }).map((_, i) => ( | |
| {Array.from({ length: Math.max(0, total - filtersForArtworksConnection.length) }).map((_, i) => ( |
MounirDhahri
left a comment
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.
Although the code might look weird with all the ifs to support different queries returning the same content, I think it would still be less work than maintaining two components that do the same thing. Maybe we can look into consolidating both into a single source of true from MP.
I lack the full context of this, so I don't feel confident to approve this (because we already have the code) or reject this, so I will leave to you to decide on how to continue with this.
| const header = useMemo(() => { | ||
| if (!data?.discoveryCategoryConnection) { | ||
| return null | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <Flex gap={2}> | ||
| <Text variant="xl" px={2}> | ||
| {title} | ||
| </Text> | ||
| <Text px={2}>Explore collections by {title.toLowerCase()}</Text> | ||
|
|
||
| <CollectionsByFilterChips discoveryCategories={data.discoveryCategoryConnection} /> | ||
| </Flex> | ||
|
|
||
| <Separator borderColor="mono10" my={4} /> | ||
| </> | ||
| ) | ||
| }, [data?.discoveryCategoryConnection, title]) |
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.
can we extract this and other components to /Components
src/app/Scenes/CollectionsByFilter/CollectionsByFilterChips.tsx
Outdated
Show resolved
Hide resolved
|
@MounirDhahri, after your comment, it made sense to expand the MP query to return distinct types since we're dealing with 2 distinct results for the same query, and they need to be together(curated collections and fake collections(artworks with some filters)). I also had this question in mind. So, I will add a different query that supports this idea bc it's a breaking change. |
|
Sorry for the late comment and thanks for looking further into this. Assuming we are speaking of the new interface, since we are still not yet live with the app and are not using this anywhere, it should theoretically be safe to making a breaking change here |
test: fix broken test and refactor the structure for a flatter test tree fix: remove test change test: fix explore by missing hrefs feat: remove extra route, incorporate the union type to render artworks with filter on the existing path
00836f1 to
c0e52b2
Compare
|
Alright, refactored the code and reused the existing route with the new Union type provided by MP artsy/metaphysics#7143 Noticed the prefetching of the Search screen was incomplete, added DiscoverSomethingNew and ExploreBy to it ⬆️ |
c0e52b2 to
16b59e1
Compare
MounirDhahri
left a comment
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.
thank you! this looks great. Also thanks for moving the files to /components
This PR resolves DIAM-49
Description
Adds support to collections made by artworks with filters on Explore By. Initially, I started with the idea of reusing the entire CollectionsByCategory, but that made the code very 🍝, including
ifannotations in GraphQL. That's why I've added a new Route for this purpose and tried to reuse what was possible.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.