Fix album tracks added as singles from Library page with iTunes source
Library page was using album data from discography listing while Artists page used track.album from API. With iTunes, these could have different track counts, causing different album_type classifications. - Updated handleAddToWishlist to use track.album data like Artists page does - Added album_type copying to owned releases in merge_discography_data
This commit is contained in:
parent
b9f2344f0f
commit
6096049c50
2 changed files with 25 additions and 3 deletions
|
|
@ -23630,6 +23630,7 @@ def merge_discography_data(owned_releases, spotify_discography):
|
|||
|
||||
# Add Spotify metadata
|
||||
owned_release['spotify_id'] = spotify_release['spotify_id']
|
||||
owned_release['album_type'] = spotify_release.get('album_type', 'album')
|
||||
owned_release['owned'] = True
|
||||
|
||||
# Calculate track completion using Spotify track count
|
||||
|
|
|
|||
|
|
@ -10678,7 +10678,28 @@ async function handleAddToWishlist() {
|
|||
artists: formattedArtists
|
||||
};
|
||||
|
||||
// Use track's album data if available (from API), falling back to modal's album data
|
||||
// This ensures consistency with how the Artists page handles wishlisting
|
||||
let trackAlbum = track.album;
|
||||
let trackAlbumType = albumType || 'album';
|
||||
|
||||
if (trackAlbum && typeof trackAlbum === 'object') {
|
||||
// Track has album data from API - use its album_type
|
||||
trackAlbumType = trackAlbum.album_type || albumType || 'album';
|
||||
// Ensure album has required fields
|
||||
if (!trackAlbum.name) {
|
||||
trackAlbum.name = album.name;
|
||||
}
|
||||
if (!trackAlbum.id) {
|
||||
trackAlbum.id = album.id;
|
||||
}
|
||||
} else {
|
||||
// Fall back to the album passed to the modal
|
||||
trackAlbum = album;
|
||||
}
|
||||
|
||||
console.log(`🔄 Adding track with formatted artists:`, formattedTrack.name, formattedTrack.artists);
|
||||
console.log(`🔄 Using album_type: ${trackAlbumType} (from ${track.album ? 'track.album' : 'modal album'})`);
|
||||
|
||||
const response = await fetch('/api/add-album-to-wishlist', {
|
||||
method: 'POST',
|
||||
|
|
@ -10688,12 +10709,12 @@ async function handleAddToWishlist() {
|
|||
body: JSON.stringify({
|
||||
track: formattedTrack,
|
||||
artist: artist,
|
||||
album: album,
|
||||
album: trackAlbum,
|
||||
source_type: 'album',
|
||||
source_context: {
|
||||
album_name: album.name,
|
||||
album_name: trackAlbum.name,
|
||||
artist_name: artist.name,
|
||||
album_type: albumType
|
||||
album_type: trackAlbumType
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue