Fix Qobuz album shuffle to start with random track and add debug logs
- Modified handleShuffleAlbum to pick random starting track (same fix as Local Library) - Added comprehensive debug logs to handleAlbumTrackPlay to diagnose queue issues - Fixed favoritesStore crash when response.tracks is undefined (defensive checks) Fixes: - Qobuz album shuffle no longer always starts with first track - App no longer crashes on startup with "undefined is not an object (evaluating 'response.tracks.items')"
This commit is contained in:
1 parent
a1220b3a06
commit
3d8c049226
2 files changed
+28
-4
No files matched your search
@@ -59,16 +59,25 @@ export async function loadFavorites(): Promise<void> {
|
||||
|
||||
isLoading = true;
|
||||
try {
|
||||
const response = await invoke<{ tracks: { items: Array<{ id: number }> } }>('get_favorites', {
|
||||
const response = await invoke<{ tracks?: { items?: Array<{ id: number }> } }>('get_favorites', {
|
||||
favType: 'track',
|
||||
limit: 500
|
||||
});
|
||||
|
||||
favoriteTrackIds = new Set(response.tracks.items.map(t => t.id));
|
||||
// Defensive: handle missing tracks or items
|
||||
if (response?.tracks?.items) {
|
||||
favoriteTrackIds = new Set(response.tracks.items.map(t => t.id));
|
||||
} else {
|
||||
// No favorites or unexpected response structure
|
||||
favoriteTrackIds = new Set();
|
||||
}
|
||||
|
||||
isLoaded = true;
|
||||
notifyListeners();
|
||||
} catch (err) {
|
||||
console.error('Failed to load favorites:', err);
|
||||
// On error, initialize as empty set
|
||||
favoriteTrackIds = new Set();
|
||||
} finally {
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user