fix(context): fix playback context tracking bugs
Multiple critical fixes for context tracking: 1. Add 'local_library' to backend context type parser - Was rejecting 'local_library' causing "Invalid context type" error - Now properly recognized in set_playback_context command 2. Fix shuffle to not always start with first track - Removed logic that moved current track to front of shuffle - Now finds current track position in shuffled order instead - Shuffle is truly random, not biased to original order 3. Add missing await to all setPlaybackContext calls - PlaylistDetailView: await context creation - FavoritesView: make setFavoritesContext async + await calls - ArtistDetailView: await context creation - HomeView: await context creation - SearchView: await + use home_list type (search type doesn't exist) This fixes intermittent context tracking (race condition) Fixes: shuffle starting with first song, Local Library context error, intermittent playlist/favorites/artist/home/search context tracking cc
This commit is contained in:
1 parent
f2c3e8aedd
commit
ed7984a029
7 files changed
+24
-20
No files matched your search
@@ -330,7 +330,7 @@
|
||||
const index = trackIndex !== undefined ? trackIndex : trackIds.indexOf(track.id);
|
||||
|
||||
if (index >= 0) {
|
||||
setPlaybackContext(
|
||||
await setPlaybackContext(
|
||||
'artist_top',
|
||||
artist.id.toString(),
|
||||
artist.name,
|
||||
|
||||
@@ -741,9 +741,9 @@
|
||||
}));
|
||||
}
|
||||
|
||||
function setFavoritesContext(trackIds: number[], index: number) {
|
||||
async function setFavoritesContext(trackIds: number[], index: number) {
|
||||
if (trackIds.length === 0) return;
|
||||
setPlaybackContext(
|
||||
await setPlaybackContext(
|
||||
'favorites',
|
||||
'favorites',
|
||||
'Favorites',
|
||||
@@ -761,7 +761,7 @@
|
||||
|
||||
async function handleTrackClick(track: FavoriteTrack, index: number) {
|
||||
const trackIds = filteredTracks.map(t => t.id);
|
||||
setFavoritesContext(trackIds, index);
|
||||
await setFavoritesContext(trackIds, index);
|
||||
|
||||
try {
|
||||
await setFavoritesQueue(index);
|
||||
@@ -779,7 +779,7 @@
|
||||
|
||||
try {
|
||||
await setFavoritesQueue(0);
|
||||
setFavoritesContext(filteredTracks.map(t => t.id), 0);
|
||||
await setFavoritesContext(filteredTracks.map(t => t.id), 0);
|
||||
onTrackPlay(buildDisplayTrack(filteredTracks[0], 0));
|
||||
} catch (err) {
|
||||
console.error('Failed to set queue:', err);
|
||||
|
||||
@@ -357,8 +357,8 @@
|
||||
// Create continue listening context
|
||||
if (continueTracks.length > 0) {
|
||||
const trackIds = continueTracks.map(t => t.id);
|
||||
|
||||
setPlaybackContext(
|
||||
|
||||
await setPlaybackContext(
|
||||
'home_list',
|
||||
'continue_listening',
|
||||
'Continue Listening',
|
||||
|
||||
@@ -585,7 +585,7 @@
|
||||
const contextIndex = trackIds.indexOf(track.id);
|
||||
|
||||
if (contextIndex >= 0 && trackIds.length > 0) {
|
||||
setPlaybackContext(
|
||||
await setPlaybackContext(
|
||||
'playlist',
|
||||
playlist.id.toString(),
|
||||
playlist.name,
|
||||
|
||||
@@ -399,9 +399,9 @@
|
||||
// Create search results context
|
||||
if (trackResults && trackResults.items.length > 0) {
|
||||
const trackIds = trackResults.items.map(t => t.id);
|
||||
|
||||
setPlaybackContext(
|
||||
'search',
|
||||
|
||||
await setPlaybackContext(
|
||||
'home_list', // Using home_list for search results (search type doesn't exist yet)
|
||||
currentQuery,
|
||||
`Search: ${currentQuery}`,
|
||||
'qobuz',
|
||||
|
||||
Reference in new issue
Block a user