perf(web-player): take the cover track ids from the list response

This commit is contained in:
2026-07-21 18:13:46 +02:00
parent 78cc2f7248
commit c1a9485d24
8 changed files with 8 additions and 54 deletions
+2
View File
@@ -581,6 +581,7 @@ export interface components {
createdAt: string;
/** Format: date-time */
updatedAt: string;
coverTrackIds: string[];
};
CreateAlbumRequest: {
title: string;
@@ -708,6 +709,7 @@ export interface components {
createdAt: string;
/** Format: date-time */
updatedAt: string;
coverTrackIds: string[];
};
PlayListPictureUploadResponse: {
/** Format: uuid */
-30
View File
@@ -52,33 +52,3 @@ export function unwrapOrFail(
): ActionFailure<{ message: string }> | undefined {
return result.error ? fail(502, { message }) : undefined;
}
export async function albumCoverTrackIds(
api: ReturnType<typeof createApiClient>,
albumIds: string[]
): Promise<Record<string, string[]>> {
const covers = await Promise.all(
albumIds.map(async (albumId) => {
const { data: tracks } = await api.GET('/albums/{albumId}/tracks', {
params: { path: { albumId }, query: { pageNumber: 1, pageSize: 4 } }
});
return [albumId, tracks?.items.map((t) => t.id) ?? []] as const;
})
);
return Object.fromEntries(covers);
}
export async function playlistCoverTrackIds(
api: ReturnType<typeof createApiClient>,
playlistIds: string[]
): Promise<Record<string, string[]>> {
const covers = await Promise.all(
playlistIds.map(async (playlistId) => {
const { data: tracks } = await api.GET('/playlists/{playlistId}/tracks', {
params: { path: { playlistId }, query: { pageNumber: 1, pageSize: 4 } }
});
return [playlistId, tracks?.items.map((t) => t.id) ?? []] as const;
})
);
return Object.fromEntries(covers);
}