Playlists are ordered collections of dumps their owners curate. This module types them, with the bodies that create, edit and reorder them. The client shows them on /@owner/playlists/:slug, on profiles and in search results.

Functions

f
comparePlaylists(sort: PlaylistSort): (
a: Playlist,
b: Playlist
) => number

Returns the comparison that puts playlists in the order sort names, as the API pages them, the newer first on a tie. usePlaylistListSync finds with it where a playlist the socket announces goes in a list.

f
parsePlaylistSort(value: string | null): PlaylistSort

Returns the order a ?sort= names, the default one when it is missing or names none: like a page number, an order never fails a list.

f
playlistActivity(playlist: Pick<Playlist, "createdAt" | "lastDumpAt">): Date

Returns when playlist last took a dump, or was created if it holds none: what the updated order sorts by and the cards show. Its title, cover and description may change after without bringing it back up a list.

Interfaces

I
CreatePlaylistRequest

Passed to POST /api/playlists by PlaylistCreateForm.

I
Playlist

Returned by the playlist routes, and by the search, users and dumps routes that list playlists. The playlist_created and playlist_updated WebSocket messages carry it too.

I
PlaylistMembership

Returned by GET /api/me/playlists?contains=:dumpId, one per playlist of the caller's. PlaylistMembershipPanel ticks the playlists with hasDump, in the add-to-playlist modal and the dump form.

I
PlaylistWithDumps

Returned by GET /api/users/:key/playlists/:slug to PlaylistDetail, and by GET /api/playlists/:playlistId, with the dumps the caller may see, in the playlist's order.

I
ReorderPlaylistRequest

Passed to PUT /api/playlists/:playlistId/order by PlaylistDetail, after a drag or to put back a dump whose removal was undone.

  • dumpIds: string[]

    Every dump of the playlist the caller can see, in the new order. The dumps hidden from them keep their slots.

I
UpdatePlaylistRequest

Passed to PUT /api/playlists/:playlistId by PlaylistDetail. A field left out keeps its value.

Type Aliases

Variables

v
PLAYLIST_SORTS: "updated" | "new" | "dumps"[]

The orders a list of playlists comes in, the first being the default one: updated, by playlistActivity, the latest first; new, by creation, the newest first; dumps, the fullest first. GET /api/playlists and GET /api/users/:key/playlists take one as ?sort=, the /playlists page and a profile's playlists tab show them as tabs and keep the one picked in their URL's ?sort=.