feat(phase35): implement context in HomeView
Context creation: - Creates 'home_list' context for Continue Listening section - Uses 'continue_listening' as ID and 'Continue Listening' as label - Tracks user's listening history in a context - Stack icon will show "Playing from: Continue Listening" Home view now fully integrated with context system. cp
This commit is contained in:
1 parent
a473c969d9
commit
640cf5db41
1 file changed
+25
-2
@@ -15,6 +15,7 @@
|
||||
type HomeSettings,
|
||||
type HomeSectionId
|
||||
} from '$lib/stores/homeSettingsStore';
|
||||
import { setPlaybackContext } from '$lib/stores/playbackContextStore';
|
||||
import type { QobuzAlbum, QobuzArtist, QobuzTrack, DisplayTrack } from '$lib/types';
|
||||
|
||||
interface TopArtistSeed {
|
||||
@@ -334,6 +335,28 @@
|
||||
return formatQuality(track.hires, track.bitDepth, track.samplingRate);
|
||||
}
|
||||
|
||||
function handleContinueTrackPlay(track: DisplayTrack, trackIndex: number) {
|
||||
// Create continue listening context
|
||||
if (continueTracks.length > 0) {
|
||||
const trackIds = continueTracks.map(t => t.id);
|
||||
|
||||
setPlaybackContext(
|
||||
'home_list',
|
||||
'continue_listening',
|
||||
'Continue Listening',
|
||||
'qobuz',
|
||||
trackIds,
|
||||
trackIndex
|
||||
);
|
||||
console.log(`[Home] Context created: Continue Listening, ${trackIds.length} tracks, starting at ${trackIndex}`);
|
||||
}
|
||||
|
||||
// Play track
|
||||
if (onTrackPlay) {
|
||||
onTrackPlay(track);
|
||||
}
|
||||
}
|
||||
|
||||
function buildTopArtistSeedsFromTracks(tracks: DisplayTrack[]): TopArtistSeed[] {
|
||||
const counts = new Map<number, number>();
|
||||
for (const track of tracks) {
|
||||
@@ -741,9 +764,9 @@
|
||||
compact={true}
|
||||
onArtistClick={track.artistId && onArtistClick ? () => onArtistClick(track.artistId!) : undefined}
|
||||
onAlbumClick={track.albumId && onAlbumClick ? () => onAlbumClick(track.albumId!) : undefined}
|
||||
onPlay={() => onTrackPlay?.(track)}
|
||||
onPlay={() => handleContinueTrackPlay(track, index)}
|
||||
menuActions={{
|
||||
onPlayNow: () => onTrackPlay?.(track)
|
||||
onPlayNow: () => handleContinueTrackPlay(track, index)
|
||||
}}
|
||||
/>
|
||||
{/each}
|
||||
|
||||
Reference in new issue
Block a user