Merge feature/ux-improvements-180226: UX improvements and playback context
Major UX improvements:
- Playback context tracking from albums/playlists/artists/favorites/home/search
- Stack icon showing context origin with clickable navigation
- Autoplay behavior setting with persistence
- Context menu actions (Play track only, Play from here)
- Track row pause on hover across all views
- Volume indicators while dragging (all 4 players)
- Favorites customization (custom icon, background, sticky nav, search)
- Theme expansion (Nord, Dracula, Tokyo Night, Catppuccin, Rosé Pine, Breeze, Adwaita)
- Layout fix: NowPlayingBar moved outside app-body flex row
Database migrations (safe for existing users 1.1.5+):
- playback_preferences table (autoplay + show_context_icon)
- favorites_preferences table (custom_icon_path, preset, icon_background, tab_order)
- Favorites icon now stored in cache dir with auto-migration
Audio backend: ✅ UNTOUCHED (bit-perfect playback preserved)
Known gaps (to fix in next branch):
- Track focus on context navigation not implemented
- Volume indicator in FocusMode/MiniPlayer not confirmed tested
# Conflicts:
# src/lib/components/AlbumCard.svelte
This commit is contained in:
commit
e2afc25175
36 files changed
+4116
-436
No files matched your search
@@ -13,8 +13,9 @@
|
||||
getStatus as getOfflineStatus,
|
||||
type OfflineStatus
|
||||
} from '$lib/stores/offlineStore';
|
||||
import { consumeContextTrackFocus, setPlaybackContext } from '$lib/stores/playbackContextStore';
|
||||
import { t } from '$lib/i18n';
|
||||
import { onMount } from 'svelte';
|
||||
import { onMount, tick } from 'svelte';
|
||||
|
||||
interface PlaylistTrack {
|
||||
id: number;
|
||||
@@ -181,6 +182,7 @@
|
||||
let loading = $state(true);
|
||||
let error = $state<string | null>(null);
|
||||
let playBtnHovered = $state(false);
|
||||
let scrollContainer: HTMLDivElement | null = $state(null);
|
||||
|
||||
// Offline mode state
|
||||
let offlineStatus = $state<OfflineStatus>(getOfflineStatus());
|
||||
@@ -197,6 +199,12 @@
|
||||
let editModalOpen = $state(false);
|
||||
let isFavorite = $state(false);
|
||||
|
||||
async function scrollToTrack(trackId: number) {
|
||||
await tick();
|
||||
const target = scrollContainer?.querySelector<HTMLElement>(`[data-track-id="${trackId}"]`);
|
||||
target?.scrollIntoView({ block: 'center' });
|
||||
}
|
||||
|
||||
// Subscribe to offline status changes
|
||||
onMount(() => {
|
||||
const unsubscribe = subscribeOffline(() => {
|
||||
@@ -209,6 +217,14 @@
|
||||
return unsubscribe;
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!playlist || displayTracks.length === 0) return;
|
||||
const targetId = consumeContextTrackFocus('playlist', playlist.id.toString());
|
||||
if (targetId !== null) {
|
||||
void scrollToTrack(targetId);
|
||||
}
|
||||
});
|
||||
|
||||
// Check if a track is available (has local copy when offline, always available when online)
|
||||
function isTrackAvailable(track: DisplayTrack): boolean {
|
||||
if (!offlineStatus.isOffline) return true;
|
||||
@@ -528,7 +544,66 @@
|
||||
return '';
|
||||
}
|
||||
|
||||
function handleTrackClick(track: DisplayTrack) {
|
||||
function buildQueueTracks(tracks: DisplayTrack[]) {
|
||||
const queueTracks = tracks.map(t => ({
|
||||
id: t.isLocal ? Math.abs(t.id) : t.id,
|
||||
title: t.title,
|
||||
artist: t.artist || 'Unknown Artist',
|
||||
album: t.album || playlist?.name || 'Playlist',
|
||||
duration_secs: t.durationSeconds,
|
||||
artwork_url: t.albumArt || getPlaylistImage(),
|
||||
hires: t.hires ?? false,
|
||||
bit_depth: t.bitDepth ?? null,
|
||||
sample_rate: t.samplingRate != null ? (t.isLocal ? t.samplingRate * 1000 : t.samplingRate) : null,
|
||||
is_local: t.isLocal ?? false,
|
||||
}));
|
||||
|
||||
const localIds = tracks
|
||||
.filter(t => t.isLocal)
|
||||
.map(t => Math.abs(t.id));
|
||||
|
||||
return { queueTracks, localIds };
|
||||
}
|
||||
|
||||
async function setPlaylistQueue(startIndex: number) {
|
||||
const allTracks = displayTracks;
|
||||
if (allTracks.length === 0) return;
|
||||
const { queueTracks, localIds } = buildQueueTracks(allTracks);
|
||||
await invoke('set_queue', { tracks: queueTracks, startIndex });
|
||||
if (localIds.length > 0) {
|
||||
onSetLocalQueue?.(localIds);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleTrackClick(track: DisplayTrack, trackIndex: number) {
|
||||
// Create playlist context before playing
|
||||
if (playlist) {
|
||||
const trackIds = displayTracks
|
||||
.filter(t => !t.isLocal) // Only Qobuz tracks in context
|
||||
.map(t => t.id);
|
||||
|
||||
const contextIndex = trackIds.indexOf(track.id);
|
||||
|
||||
if (contextIndex >= 0 && trackIds.length > 0) {
|
||||
setPlaybackContext(
|
||||
'playlist',
|
||||
playlist.id.toString(),
|
||||
playlist.name,
|
||||
'qobuz',
|
||||
trackIds,
|
||||
contextIndex
|
||||
);
|
||||
console.log(`[Playlist] Context created: "${playlist.name}", ${trackIds.length} tracks, starting at ${contextIndex}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle playback
|
||||
try {
|
||||
await setPlaylistQueue(trackIndex);
|
||||
} catch (err) {
|
||||
console.error('Failed to set queue:', err);
|
||||
}
|
||||
|
||||
if (track.isLocal && track.localTrackId) {
|
||||
// Handle local track play
|
||||
const localTrack = localTracksMap.get(track.localTrackId);
|
||||
@@ -590,32 +665,8 @@
|
||||
const allTracks = displayTracks;
|
||||
if (allTracks.length === 0) return;
|
||||
|
||||
// Build queue tracks, using absolute ID for local tracks
|
||||
const queueTracks = allTracks.map(t => ({
|
||||
id: t.isLocal ? Math.abs(t.id) : t.id,
|
||||
title: t.title,
|
||||
artist: t.artist || 'Unknown Artist',
|
||||
album: t.album || playlist?.name || 'Playlist',
|
||||
duration_secs: t.durationSeconds,
|
||||
artwork_url: t.albumArt || getPlaylistImage(),
|
||||
hires: t.hires ?? false,
|
||||
bit_depth: t.bitDepth ?? null,
|
||||
sample_rate: t.samplingRate != null ? (t.isLocal ? t.samplingRate * 1000 : t.samplingRate) : null,
|
||||
is_local: t.isLocal ?? false,
|
||||
}));
|
||||
|
||||
// Collect local track IDs (original positive IDs)
|
||||
const localIds = allTracks
|
||||
.filter(t => t.isLocal)
|
||||
.map(t => Math.abs(t.id));
|
||||
|
||||
try {
|
||||
await invoke('set_queue', { tracks: queueTracks, startIndex: 0 });
|
||||
|
||||
// Tell parent about local tracks in queue
|
||||
if (localIds.length > 0) {
|
||||
onSetLocalQueue?.(localIds);
|
||||
}
|
||||
await setPlaylistQueue(0);
|
||||
|
||||
// Play first track (handle local vs Qobuz)
|
||||
const firstTrack = allTracks[0];
|
||||
@@ -745,7 +796,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="playlist-detail">
|
||||
<div class="playlist-detail" bind:this={scrollContainer}>
|
||||
<!-- Navigation Row -->
|
||||
<div class="nav-row">
|
||||
<button class="back-btn" onclick={onBack}>
|
||||
@@ -953,11 +1004,11 @@
|
||||
hideDownload={track.isLocal}
|
||||
downloadStatus={downloadInfo.status}
|
||||
downloadProgress={downloadInfo.progress}
|
||||
onPlay={available ? () => handleTrackClick(track) : undefined}
|
||||
onPlay={available ? () => handleTrackClick(track, idx) : undefined}
|
||||
onDownload={available && !track.isLocal && onTrackDownload ? () => onTrackDownload(track) : undefined}
|
||||
onRemoveDownload={available && !track.isLocal && onTrackRemoveDownload ? () => onTrackRemoveDownload(track.id) : undefined}
|
||||
menuActions={available ? {
|
||||
onPlayNow: () => handleTrackClick(track),
|
||||
onPlayNow: () => handleTrackClick(track, idx),
|
||||
onPlayNext: track.isLocal ? () => handleTrackPlayNext(track) : (onTrackPlayNext ? () => onTrackPlayNext(track) : undefined),
|
||||
onPlayLater: track.isLocal ? () => handleTrackPlayLater(track) : (onTrackPlayLater ? () => onTrackPlayLater(track) : undefined),
|
||||
onAddToPlaylist: !track.isLocal && onTrackAddToPlaylist ? () => onTrackAddToPlaylist(track.id) : undefined,
|
||||
|
||||
Reference in new issue
Block a user