Skip to content

Conversation

@araujobarret
Copy link
Contributor

@araujobarret araujobarret commented Sep 26, 2025

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 if annotations in GraphQL. That's why I've added a new Route for this purpose and tried to reuse what was possible.

PR Checklist

  • I have tested my changes on the following platforms:
    • Android.
    • iOS.
  • I hid my changes behind a feature flag, or they don't need one.
  • I have included screenshots or videos at least on Android, 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

  • feat: support artworks with filters as collections in Explore By

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.

@araujobarret araujobarret requested review from a team, iskounen and nickskalkin September 26, 2025 12:21
@araujobarret araujobarret self-assigned this Sep 26, 2025
@araujobarret araujobarret changed the title feat(DIAM-59): collections by filtered artworks feat(DIAM-49): collections by filtered artworks Sep 26, 2025
@ArtsyOpenSource
Copy link
Contributor

ArtsyOpenSource commented Sep 26, 2025

This PR contains the following changes:

  • Cross-platform user-facing changes (feat: support artworks with filters as collections in Explore By - araujobarret)

Generated by 🚫 dangerJS against 16b59e1

Copy link
Contributor

@nickskalkin nickskalkin 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 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

@MounirDhahri
Copy link
Member

Thanks for the tag @nickskalkin looking into it now

Copy link
Contributor

Copilot AI left a 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.

const collections = extractNodes(data.chipsFilteredCollections)

const numRows = !isTablet() ? 3 : 2
const numColumns = Math.ceil(collections.length / 3)
Copy link

Copilot AI Sep 26, 2025

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.

Suggested change
const numColumns = Math.ceil(collections.length / 3)
const numColumns = Math.ceil(collections.length / numRows)

Copilot uses AI. Check for mistakes.
return (
<>
<Separator borderColor="mono10" mt={4} />
{Array.from({ length: total - filtersForArtworksConnection.length }).map((_, i) => (
Copy link

Copilot AI Sep 26, 2025

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.

Suggested change
{Array.from({ length: total - filtersForArtworksConnection.length }).map((_, i) => (
{Array.from({ length: Math.max(0, total - filtersForArtworksConnection.length) }).map((_, i) => (

Copilot uses AI. Check for mistakes.
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.

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.

Comment on lines 43 to 62
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])
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 extract this and other components to /Components

@araujobarret
Copy link
Contributor Author

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

@MounirDhahri
Copy link
Member

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
@araujobarret araujobarret force-pushed the araujobarret/dia-1383/explore-by-price-categories branch from 00836f1 to c0e52b2 Compare October 9, 2025 11:31
@araujobarret
Copy link
Contributor Author

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 ⬆️

@araujobarret araujobarret force-pushed the araujobarret/dia-1383/explore-by-price-categories branch from c0e52b2 to 16b59e1 Compare October 9, 2025 11:35
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.

thank you! this looks great. Also thanks for moving the files to /components

@araujobarret araujobarret merged commit ce328b9 into main Oct 13, 2025
7 checks passed
@araujobarret araujobarret deleted the araujobarret/dia-1383/explore-by-price-categories branch October 13, 2025 13:20
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.

5 participants