feat(local-library): implement playback context tracking
Add proper context tracking for Local Library playback so the stack icon shows correctly when playing from Local Library. Changes: - Add 'local_library' to ContextType enum (frontend and backend) - Add 'Local Library' display label in context info - Import setPlaybackContext in LocalLibraryView - Call setPlaybackContext when playing tracks from Local Library - For album view: context is the album with album title - For tracks view: context is "Local Tracks" - Track IDs and position are properly set for context navigation Fixes issue where Local Library playback showed stale Qobuz context. cc
This commit is contained in:
1 parent
873dcee10e
commit
f2c3e8aedd
3 files changed
+32
-2
No files matched your search
@@ -22,6 +22,7 @@ pub enum ContextType {
|
||||
ArtistTop,
|
||||
HomeList,
|
||||
Favorites,
|
||||
LocalLibrary,
|
||||
}
|
||||
|
||||
/// Source of the content (Qobuz or Local Library)
|
||||
@@ -120,6 +121,7 @@ impl PlaybackContext {
|
||||
ContextType::ArtistTop => "Artist Top Songs",
|
||||
ContextType::HomeList => "Home List",
|
||||
ContextType::Favorites => "Favorites",
|
||||
ContextType::LocalLibrary => "Local Library",
|
||||
};
|
||||
format!("{} · {}", type_str, self.label)
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
subscribe as subscribeOffline,
|
||||
isOffline as checkIsOffline
|
||||
} from '$lib/stores/offlineStore';
|
||||
import {
|
||||
setPlaybackContext
|
||||
} from '$lib/stores/playbackContextStore';
|
||||
|
||||
// Backend types matching Rust models
|
||||
interface LocalTrack {
|
||||
@@ -716,10 +719,34 @@
|
||||
try {
|
||||
if (selectedAlbum && albumTracks.length > 0) {
|
||||
const trackIndex = albumTracks.findIndex(t => t.id === track.id);
|
||||
const trackIds = albumTracks.map(t => t.id);
|
||||
|
||||
// Set playback context for Local Library album
|
||||
await setPlaybackContext(
|
||||
'local_library',
|
||||
selectedAlbum.id,
|
||||
selectedAlbum.title,
|
||||
'local',
|
||||
trackIds,
|
||||
trackIndex >= 0 ? trackIndex : 0
|
||||
);
|
||||
|
||||
await setQueueForAlbumTracks(albumTracks, trackIndex >= 0 ? trackIndex : 0);
|
||||
} else if (activeTab === 'tracks' && tracks.length > 0) {
|
||||
const orderedTracks = getDisplayedTrackOrder();
|
||||
const trackIndex = orderedTracks.findIndex(t => t.id === track.id);
|
||||
const trackIds = orderedTracks.map(t => t.id);
|
||||
|
||||
// Set playback context for Local Library tracks view
|
||||
await setPlaybackContext(
|
||||
'local_library',
|
||||
'local-tracks',
|
||||
'Local Tracks',
|
||||
'local',
|
||||
trackIds,
|
||||
trackIndex >= 0 ? trackIndex : 0
|
||||
);
|
||||
|
||||
await setQueueForLocalTracks(orderedTracks, trackIndex >= 0 ? trackIndex : 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { invoke } from '@tauri-apps/api/core';
|
||||
|
||||
// ============ Types ============
|
||||
|
||||
export type ContextType = 'album' | 'playlist' | 'artist_top' | 'home_list' | 'favorites';
|
||||
export type ContextType = 'album' | 'playlist' | 'artist_top' | 'home_list' | 'favorites' | 'local_library';
|
||||
export type ContentSource = 'qobuz' | 'local';
|
||||
|
||||
export interface PlaybackContext {
|
||||
@@ -138,7 +138,8 @@ export function getContextDisplayInfo(): string | null {
|
||||
playlist: 'Playlist',
|
||||
artist_top: 'Artist Top Songs',
|
||||
home_list: 'Home List',
|
||||
favorites: 'Favorites'
|
||||
favorites: 'Favorites',
|
||||
local_library: 'Local Library'
|
||||
}[currentContext.type];
|
||||
|
||||
return `${typeStr} · ${currentContext.label}`;
|
||||
|
||||
Reference in new issue
Block a user