feat(web/m7-352): kind-aware createPlaylistsQuery + system-playlists-status helper

This commit is contained in:
2026-05-04 18:30:43 -04:00
parent 56f0998f84
commit 886903ae27
4 changed files with 57 additions and 7 deletions
+8 -5
View File
@@ -3,13 +3,16 @@ import { apiFetch } from './client';
import { qk } from './queries';
import type { Playlist, PlaylistDetail } from './types';
export type PlaylistKind = 'user' | 'system' | 'all';
export type ListPlaylistsResponse = {
owned: Playlist[];
public: Playlist[];
};
export async function listPlaylists(): Promise<ListPlaylistsResponse> {
return (await apiFetch('/api/playlists', { method: 'GET' })) as ListPlaylistsResponse;
export async function listPlaylists(kind?: PlaylistKind): Promise<ListPlaylistsResponse> {
const k = kind ?? 'user';
return (await apiFetch(`/api/playlists?kind=${k}`, { method: 'GET' })) as ListPlaylistsResponse;
}
export async function getPlaylist(id: string): Promise<PlaylistDetail> {
@@ -73,10 +76,10 @@ export async function reorderPlaylist(playlistID: string, orderedPositions: numb
})) as PlaylistDetail;
}
export function createPlaylistsQuery() {
export function createPlaylistsQuery(kind?: PlaylistKind) {
return createQuery({
queryKey: qk.playlists(),
queryFn: listPlaylists,
queryKey: qk.playlists(kind),
queryFn: () => listPlaylists(kind),
staleTime: 30_000
});
}