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
@@ -1,7 +1,6 @@
import type { PageServerLoad, Actions } from './$types';
import { fail, redirect } from '@sveltejs/kit';
import {
albumCoverTrackIds,
createApiClient,
requireAccessTokenAction,
requireUser,
@@ -19,12 +18,8 @@ export const load: PageServerLoad = async ({ locals, url, fetch }) => {
});
const albums = unwrapOrError(result, 'No se pudieron cargar tus álbumes.');
const trackIds = await albumCoverTrackIds(
api,
albums.items.map((album) => album.id)
);
return { albums, trackIds };
return { albums };
};
export const actions: Actions = {
@@ -13,7 +13,6 @@
let { data, form } = $props();
const items = $derived(data.albums.items);
const trackIds = $derived(data.trackIds);
let creating = $state(false);
</script>
@@ -43,7 +42,7 @@
title={album.title}
releaseYear={album.releaseYear === null ? undefined : Number(album.releaseYear)}
trackCount={Number(album.trackCount)}
trackIds={trackIds[album.id] ?? []}
trackIds={album.coverTrackIds}
index={i}
/>
{/each}
@@ -2,7 +2,6 @@ import type { PageServerLoad, Actions } from './$types';
import { fail, redirect } from '@sveltejs/kit';
import {
createApiClient,
playlistCoverTrackIds,
requireAccessTokenAction,
requireUser,
unwrapOrError
@@ -19,12 +18,8 @@ export const load: PageServerLoad = async ({ locals, url, fetch }) => {
});
const data = unwrapOrError(result, 'No se pudieron cargar tus playlists.');
const trackIds = await playlistCoverTrackIds(
api,
data.items.map((p) => p.id)
);
return { playlists: data, trackIds };
return { playlists: data };
};
export const actions: Actions = {
@@ -32,7 +32,6 @@
let { data, form } = $props();
const items = $derived(data.playlists.items);
const trackIds = $derived(data.trackIds);
let creating = $state(false);
@@ -65,7 +64,7 @@
id={playlist.id}
name={playlist.name}
description={playlist.description}
trackIds={trackIds[playlist.id] ?? []}
trackIds={playlist.coverTrackIds}
updatedAt={playlist.updatedAt}
index={i}
/>