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.
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.
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.
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.
Passed to POST /api/playlists by PlaylistCreateForm.
-
categoryIds: string[]
The playlist categories to file it under, none when left out.
- description: string
- isPublic: boolean
- title: string
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.
-
categoryIds: string[]
The ids of the playlist categories it is filed under. The services fill them in on every playlist they return.
- createdAt: Date
-
description: string
It is written in Markdown.
-
dumpCount: number
It counts the dumps the viewer may see in it, as its page lists them. It is undefined when the query didn't count them.
- id: string
-
imageMime: string
It is undefined when the playlist has no cover.
-
isPublic: boolean
Only its owner sees a private playlist. Moderators don't, though they may still edit or delete it.
-
lastDumpAt: Date
When the latest of the dumps the viewer may see was added to it, which playlistActivity reads. It is undefined when it holds none, or when the query didn't count them.
-
ownerUsername: string
The owner's current name, which the playlist's path starts with.
-
slug: string
Names the playlist in its page's path,
playlistPath(shared/paths.ts) building it with ownerUsername. Made from the title on creation, it changes only when edited, and is unique among its owner's playlists. - title: string
-
updatedAt: Date
playlistImageUrlputs it on the cover's URL, so a new cover isn't hidden by the cached old one. - userId: string
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.
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.
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.
Passed to PUT /api/playlists/:playlistId by PlaylistDetail. A field left
out keeps its value.
-
categoryIds: string[]
Replaces its playlist categories;
[]takes it out of every one. -
description: string | null
nullremoves the description. - isPublic: boolean
-
slug: string
A new slug, which the edit form's slug field sends. A title change never changes the slug by itself.
- title: string
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=.
Usage
import * as mod from "shared/playlist.ts";