feat(web): shared collection header, Play and Shuffle, and the centred page column (M494)
release / govulncheck (push) Successful in 42s
release / web (push) Successful in 1m30s
release / go (push) Successful in 1m48s
release / integration (push) Successful in 5m51s
release / android (push) Successful in 6m53s
release / Build signed APK (releases and dev) (push) Successful in 7m14s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 1m29s
release / Verify release artifacts (tag releases only) (push) Skipped
release / govulncheck (push) Successful in 42s
release / web (push) Successful in 1m30s
release / go (push) Successful in 1m48s
release / integration (push) Successful in 5m51s
release / android (push) Successful in 6m53s
release / Build signed APK (releases and dev) (push) Successful in 7m14s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 1m29s
release / Verify release artifacts (tag releases only) (push) Skipped
- CollectionHeader holds cover, title, facts, then Play and Shuffle, for album and playlist. The playlist page gains Play and Shuffle; it had neither. The cover uses the shared Cover component, so the playlist header also gets the fallback image. - PlayActions is the one Play and Shuffle pair: filled Play, outlined Shuffle, on album, playlist and artist pages (operator, 2026-10-08). The artist page's round icon button said Play but shuffled; Play now keeps the server's order, and Shuffle shuffles. - PageColumn is the playlist page's centred column, now used by album, playlist, Liked, History and Search → Tracks. - The playlist page builds its queue with playlistTrackToRef, the shared converter, in place of its own copy. Its copy skipped only removed tracks, so a missing file (#2527) could still be queued from there. - shuffled() in lib/utils is the one shuffle, replacing three private copies (album page, artist page, ArtistCard). - The album's refetch error now uses text-error-fg. `text-oxblood` is not a colour in the theme, so it never rendered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import PageColumn from '#lib/components/PageColumn.svelte';
|
||||
import { page } from '$app/state';
|
||||
import { goto } from '$app/navigation';
|
||||
import { untrack } from 'svelte';
|
||||
@@ -7,6 +8,9 @@
|
||||
import { useQueryClient } from '@tanstack/svelte-query';
|
||||
import PlaylistTrackRow from '#lib/components/PlaylistTrackRow.svelte';
|
||||
import TrackList from '#lib/components/TrackList.svelte';
|
||||
import CollectionHeader from '#lib/components/CollectionHeader.svelte';
|
||||
import { playlistTrackToRef } from '#lib/playlists/playlistTrackToRef.js';
|
||||
import { shuffled } from '#lib/utils/shuffle.js';
|
||||
import ApiErrorBanner from '#lib/components/ApiErrorBanner.svelte';
|
||||
import {
|
||||
createPlaylistQuery,
|
||||
@@ -75,23 +79,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
function onPlay(position: number) {
|
||||
if (!playlistQuery?.data) return;
|
||||
const data = playlistQuery.data;
|
||||
// Skip rows where track_id is null (track was removed from library).
|
||||
const live = data.tracks.filter((t) => t.track_id !== null).map(toTrackRef);
|
||||
// Find which `live` index corresponds to the clicked position. Some
|
||||
// positions in the original list may be unavailable (filtered out),
|
||||
// so the index in the playable list != the playlist position.
|
||||
const clickedTrackID = data.tracks.find((t) => t.position === position)?.track_id;
|
||||
const startIdx = live.findIndex((t) => t.id === clickedTrackID);
|
||||
// Every entry that can be played, in playlist order. playlistTrackToRef
|
||||
// drops both kinds of dead entry, removed tracks and missing files
|
||||
// (#2527), so neither is ever queued.
|
||||
function playable(data: PlaylistDetail): { refs: TrackRef[]; positions: number[] } {
|
||||
const refs: TrackRef[] = [];
|
||||
const positions: number[] = [];
|
||||
for (const row of data.tracks) {
|
||||
const ref = playlistTrackToRef(row);
|
||||
if (ref) {
|
||||
refs.push(ref);
|
||||
positions.push(row.position);
|
||||
}
|
||||
}
|
||||
return { refs, positions };
|
||||
}
|
||||
|
||||
function startQueue(data: PlaylistDetail, tracks: TrackRef[], startIdx: number) {
|
||||
// #968: a system playlist played from its detail page is tagged with its
|
||||
// source (so play_started advances the rotation, matching the home tile and
|
||||
// the Android detail screen) and gets the self-heal closure so a stale
|
||||
// snapshot re-pulls on total failure.
|
||||
const variant = data.system_variant;
|
||||
if (variant != null) {
|
||||
playQueue(live, Math.max(0, startIdx), {
|
||||
playQueue(tracks, Math.max(0, startIdx), {
|
||||
source: variant,
|
||||
refetch: systemPlaylistRefetch({
|
||||
variant,
|
||||
@@ -100,30 +111,25 @@
|
||||
})
|
||||
});
|
||||
} else {
|
||||
playQueue(live, Math.max(0, startIdx));
|
||||
playQueue(tracks, Math.max(0, startIdx));
|
||||
}
|
||||
}
|
||||
|
||||
function toTrackRef(t: {
|
||||
track_id: string | null;
|
||||
album_id: string | null;
|
||||
artist_id: string | null;
|
||||
title: string;
|
||||
album_title: string;
|
||||
artist_name: string;
|
||||
duration_sec: number;
|
||||
stream_url: string | null;
|
||||
}): TrackRef {
|
||||
return {
|
||||
id: t.track_id!,
|
||||
title: t.title,
|
||||
album_id: t.album_id ?? '',
|
||||
album_title: t.album_title,
|
||||
artist_id: t.artist_id ?? '',
|
||||
artist_name: t.artist_name,
|
||||
duration_sec: t.duration_sec,
|
||||
stream_url: t.stream_url ?? ''
|
||||
} as unknown as TrackRef;
|
||||
function onPlay(position: number) {
|
||||
if (!playlistQuery?.data) return;
|
||||
const data = playlistQuery.data;
|
||||
const { refs, positions } = playable(data);
|
||||
startQueue(data, refs, positions.indexOf(position));
|
||||
}
|
||||
|
||||
function onPlayAll() {
|
||||
if (!playlistQuery?.data) return;
|
||||
startQueue(playlistQuery.data, playable(playlistQuery.data).refs, 0);
|
||||
}
|
||||
|
||||
function onShuffle() {
|
||||
if (!playlistQuery?.data) return;
|
||||
startQueue(playlistQuery.data, shuffled(playable(playlistQuery.data).refs), 0);
|
||||
}
|
||||
|
||||
let editing = $state(false);
|
||||
@@ -229,7 +235,7 @@
|
||||
<title>{pageTitle(playlistQuery?.data?.name ? `Playlist · ${playlistQuery.data.name}` : 'Playlist')}</title>
|
||||
</svelte:head>
|
||||
|
||||
<div class="mx-auto max-w-4xl px-4 py-6">
|
||||
<PageColumn>
|
||||
{#if playlistQuery?.isPending}
|
||||
<p class="text-text-muted">Loading…</p>
|
||||
{:else if playlistQuery?.isError}
|
||||
@@ -255,64 +261,64 @@
|
||||
</div>
|
||||
{/if}
|
||||
{#if !editing}
|
||||
<header class="mb-6 flex items-start gap-4">
|
||||
<div class="h-32 w-32 shrink-0 overflow-hidden rounded-md bg-surface-hover">
|
||||
{#if pl.cover_url}
|
||||
<img src={pl.cover_url} alt="" class="h-full w-full object-cover" />
|
||||
<CollectionHeader
|
||||
title={pl.name}
|
||||
coverUrl={pl.cover_url}
|
||||
playDisabled={!pl.tracks.some((t) => playlistTrackToRef(t) !== null)}
|
||||
onPlay={onPlayAll}
|
||||
{onShuffle}
|
||||
>
|
||||
{#if pl.description}
|
||||
<p class="text-sm text-text-muted">{pl.description}</p>
|
||||
{/if}
|
||||
<p class="text-xs text-text-muted">
|
||||
{pl.track_count} {pl.track_count === 1 ? 'track' : 'tracks'}
|
||||
{#if pl.is_public}· public{:else}· private{/if}
|
||||
{#if !isOwner}· by {pl.owner_username}{/if}
|
||||
</p>
|
||||
{#snippet tools()}
|
||||
{#if pl.refreshable && pl.system_variant}
|
||||
<button
|
||||
type="button"
|
||||
disabled={refreshingSystem}
|
||||
onclick={() => onRefreshSystem(pl.system_variant as string)}
|
||||
class="rounded-md border border-border px-3 py-1.5 text-sm text-text-muted hover:text-text-primary"
|
||||
aria-label="Refresh playlist"
|
||||
>
|
||||
{refreshingSystem ? 'Refreshing…' : 'Refresh'}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<h1 class="truncate text-2xl font-medium text-text-primary">{pl.name}</h1>
|
||||
{#if pl.description}
|
||||
<p class="mt-1 text-sm text-text-muted">{pl.description}</p>
|
||||
{#if isOwner && pl.is_public}
|
||||
<button
|
||||
type="button"
|
||||
onclick={onCopyLink}
|
||||
aria-label="Copy public link to this playlist"
|
||||
title="Copy link"
|
||||
class="rounded p-2 text-text-muted hover:bg-surface-hover hover:text-text-primary"
|
||||
>
|
||||
<LinkIcon size={16} strokeWidth={1} />
|
||||
</button>
|
||||
{/if}
|
||||
<p class="mt-2 text-xs text-text-muted">
|
||||
{pl.track_count} {pl.track_count === 1 ? 'track' : 'tracks'}
|
||||
{#if pl.is_public}· public{:else}· private{/if}
|
||||
{#if !isOwner}· by {pl.owner_username}{/if}
|
||||
</p>
|
||||
</div>
|
||||
{#if pl.refreshable && pl.system_variant}
|
||||
<button
|
||||
type="button"
|
||||
disabled={refreshingSystem}
|
||||
onclick={() => onRefreshSystem(pl.system_variant as string)}
|
||||
class="rounded-md border border-border px-3 py-1.5 text-sm text-text-muted hover:text-text-primary"
|
||||
aria-label="Refresh playlist"
|
||||
>
|
||||
{refreshingSystem ? 'Refreshing…' : 'Refresh'}
|
||||
</button>
|
||||
{/if}
|
||||
{#if isOwner && pl.is_public}
|
||||
<button
|
||||
type="button"
|
||||
onclick={onCopyLink}
|
||||
aria-label="Copy public link to this playlist"
|
||||
title="Copy link"
|
||||
class="rounded p-2 text-text-muted hover:bg-surface-hover hover:text-text-primary"
|
||||
>
|
||||
<LinkIcon size={16} strokeWidth={1} />
|
||||
</button>
|
||||
{/if}
|
||||
{#if isOwner}
|
||||
<button
|
||||
type="button"
|
||||
onclick={startEdit}
|
||||
aria-label="Edit playlist"
|
||||
class="rounded p-2 text-text-muted hover:bg-surface-hover hover:text-text-primary"
|
||||
>
|
||||
<Pencil size={16} strokeWidth={1} />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onclick={submitDelete}
|
||||
aria-label="Delete playlist"
|
||||
class="rounded p-2 text-text-muted hover:bg-surface-hover hover:text-action-destructive"
|
||||
>
|
||||
<Trash2 size={16} strokeWidth={1} />
|
||||
</button>
|
||||
{/if}
|
||||
</header>
|
||||
{#if isOwner}
|
||||
<button
|
||||
type="button"
|
||||
onclick={startEdit}
|
||||
aria-label="Edit playlist"
|
||||
class="rounded p-2 text-text-muted hover:bg-surface-hover hover:text-text-primary"
|
||||
>
|
||||
<Pencil size={16} strokeWidth={1} />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onclick={submitDelete}
|
||||
aria-label="Delete playlist"
|
||||
class="rounded p-2 text-text-muted hover:bg-surface-hover hover:text-action-destructive"
|
||||
>
|
||||
<Trash2 size={16} strokeWidth={1} />
|
||||
</button>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</CollectionHeader>
|
||||
{:else}
|
||||
<section class="mb-6 rounded-md border border-border bg-surface p-4">
|
||||
<label class="block text-sm font-medium text-text-primary">
|
||||
@@ -376,4 +382,4 @@
|
||||
</TrackList>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</PageColumn>
|
||||
|
||||
Reference in New Issue
Block a user