feat(web): add home/albums/artists API clients for M6a

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-01 20:13:49 -04:00
co-authored by Claude Sonnet 4.6
parent b1f2227d62
commit e674869e06
6 changed files with 145 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import { createInfiniteQuery } from '@tanstack/svelte-query';
import { api } from './client';
import { qk } from './queries';
import type { AlbumRef, Page } from './types';
export const ALBUM_PAGE_SIZE = 50;
export async function listAlbumsAlpha(limit: number, offset: number): Promise<Page<AlbumRef>> {
return api.get<Page<AlbumRef>>(`/api/library/albums?limit=${limit}&offset=${offset}`);
}
export function createAlbumsAlphaInfiniteQuery() {
return createInfiniteQuery({
queryKey: qk.albumsAlpha(),
queryFn: ({ pageParam = 0 }) => listAlbumsAlpha(ALBUM_PAGE_SIZE, pageParam),
initialPageParam: 0,
getNextPageParam: (last) => {
const loaded = last.offset + last.items.length;
return loaded >= last.total ? undefined : loaded;
}
});
}