feat(web/playlists): Discover refresh button (detail + home kebab)

Operator can refresh their Discover playlist without waiting for
the next daily cron tick. Two surfaces, both gated on
system_variant === 'discover':

- Detail page header: "Refresh" button next to the cover art / meta.
- Home Playlists row tile kebab: "Refresh Discover" menu item.

Both call POST /api/playlists/system/discover/refresh, show a
confirmation toast, and invalidate the playlist + playlists queries
so the new content lands without a manual page reload.

Extends Playlist.system_variant union with 'discover'. Adds
refreshDiscover() typed client. Tests cover client behaviour
(success + empty-library) plus conditional rendering on both
surfaces.
This commit is contained in:
2026-05-07 08:44:33 -04:00
parent 0ba31c7816
commit b20738f925
7 changed files with 309 additions and 8 deletions
+17
View File
@@ -91,3 +91,20 @@ export function createPlaylistQuery(id: string) {
staleTime: 30_000
});
}
// System playlist refresh ----------------------------------------------------
export type RefreshDiscoverResponse = {
playlist_id: string | null;
track_count: number;
};
// Re-runs the daily system playlist build for the calling user and
// returns the resulting Discover playlist's id + track count.
// Used by the detail-page Refresh button and the home tile kebab.
export async function refreshDiscover(): Promise<RefreshDiscoverResponse> {
return (await apiFetch('/api/playlists/system/discover/refresh', {
method: 'POST',
body: JSON.stringify({})
})) as RefreshDiscoverResponse;
}