ArtListing
app/features/art/core/ArtListing.tsNarrowing down a list of art the way the art pages do: a user's art by whether they made it or are in it and by tag, the tags offered to filter by, artists taking commissions and the page of the grid an art is on. A user's own art comes without an author (see ArtRepository.findArtsByUserId), art made of them by someone else with one.
- Imports
- no other modules
- Used by
- 1 loader2 routes1 component
Functions & values
The art of a user's page shown with the source and tag picked. The source only narrows the list when the user has both art they made and art made of them ({@link hasBothSources}), as only then is it offered. A tag narrows it to the art having that tag.
export function filterUserArts<T extends UserArt>( arts: T[], { source, tag }: { source: ArtSource; tag: string | null }, )
Unit tests (3)
Does the user have both art they made and art made of them by someone else?
export function hasBothSources(arts: UserArt[])
Unit tests (1)
Names of the tags of the art with how many pieces have each, most used first. null when no art has tags.
export function tagCounts(arts: Pick<ListedArt, "tags">[])
The art whose author has their commissions open.
export function withCommissionsOpen<T extends Pick<ListedArt, "author">>( arts: T[], )
Unit tests (1)
The page of the art grid (ART_PER_PAGE pieces each, counting from one) the art is on, so that a shared ?big= link opens the page containing it. The first page if the art is not in the list.
export function pageOf(arts: Pick<ListedArt, "id">[], artId: number | null)