web-player: fix playlist ownership, sidebar counts, home spotlight and assorted page bugs

This commit is contained in:
2026-09-24 05:02:26 +02:00
parent dda8c30d45
commit bc43b4b6eb
21 changed files with 216 additions and 232 deletions
@@ -9,6 +9,8 @@
import Plus from '@lucide/svelte/icons/plus';
import Logo from '../ui/primitives/Logo.svelte';
const SIDEBAR_PLAYLISTS_LIMIT = 8;
interface SidebarPlaylist {
id: string;
name: string;
@@ -19,11 +21,14 @@
interface Props {
user: SessionUser | null;
playlists: SidebarPlaylist[];
playlistCount: number;
}
let { user, playlists }: Props = $props();
let { user, playlists, playlistCount }: Props = $props();
const navLinks = $derived(appNavLinks(user, { playlists: playlists.length, liked: liked.count }));
const visiblePlaylists = $derived(playlists.slice(0, SIDEBAR_PLAYLISTS_LIMIT));
const navLinks = $derived(appNavLinks(user, { playlists: playlistCount, liked: liked.count }));
function isActive(href: string) {
return isSectionActive(href, page.url.pathname, page.data.section);
@@ -61,7 +66,7 @@
<div class="mx-3 mt-6 mb-3.5 h-px bg-line"></div>
<div class="flex items-center justify-between px-3 pb-1.5">
<span class="text-eyebrow text-fg-2">Tus playlists</span>
{#if playlists.length > 0}
{#if visiblePlaylists.length > 0}
<IconButton
label="Crear playlist"
tone="plain"
@@ -74,7 +79,7 @@
</div>
<div class="flex min-h-0 flex-1 flex-col gap-px overflow-y-auto pb-icon-md">
{#each playlists as playlist (playlist.id)}
{#each visiblePlaylists as playlist (playlist.id)}
{@const active = page.url.pathname === `/playlists/${playlist.id}`}
<ListRow
href="/playlists/{playlist.id}"
@@ -37,9 +37,16 @@
function onInput(event: Event) {
const file = (event.currentTarget as HTMLInputElement).files?.[0];
if (!file) return;
releasePreview();
preview = URL.createObjectURL(file);
onselect?.(file);
}
function releasePreview() {
if (preview !== '') URL.revokeObjectURL(preview);
}
$effect(() => releasePreview);
</script>
<label
@@ -61,7 +61,7 @@
{/if}
<MenuItem
icon={themeMode.current === 'dark' ? Sun : Moon}
label={themeMode.current === 'dark' ? 'Modo blanco' : 'Modo oscuro'}
label={themeMode.current === 'dark' ? 'Modo claro' : 'Modo oscuro'}
onclick={() => themeMode.toggle()}
/>
<form method="POST" action="/auth/logout" data-sveltekit-reload>
@@ -9,15 +9,19 @@
description: string;
confirmLabel: string;
action: string;
fields?: Record<string, string>;
}
let { open, onClose, title, description, confirmLabel, action }: Props = $props();
let { open, onClose, title, description, confirmLabel, action, fields = {} }: Props = $props();
</script>
<Dialog {open} {onClose} {title} {description}>
{#snippet actions()}
<Button variant="secondary" onclick={onClose}>Cancelar</Button>
<form method="POST" {action}>
{#each Object.entries(fields) as [name, value] (name)}
<input type="hidden" {name} {value} />
{/each}
<Button type="submit" variant="danger">{confirmLabel}</Button>
</form>
{/snippet}