Update script.js
This commit is contained in:
parent
961156d628
commit
909e5e59de
1 changed files with 21 additions and 5 deletions
|
|
@ -11914,6 +11914,8 @@ async function handleArtistAlbumClick(album, albumType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showLoadingOverlay('Loading album...');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check completion status of the album
|
// Check completion status of the album
|
||||||
const completionStatus = getAlbumCompletionStatus(album.id, albumType);
|
const completionStatus = getAlbumCompletionStatus(album.id, albumType);
|
||||||
|
|
@ -11921,6 +11923,7 @@ async function handleArtistAlbumClick(album, albumType) {
|
||||||
|
|
||||||
// If album is complete, show informational message and exit
|
// If album is complete, show informational message and exit
|
||||||
if (completionStatus?.status === 'completed') {
|
if (completionStatus?.status === 'completed') {
|
||||||
|
hideLoadingOverlay();
|
||||||
showToast(`${album.name} is already complete in your library`, 'info');
|
showToast(`${album.name} is already complete in your library`, 'info');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -11940,14 +11943,17 @@ async function handleArtistAlbumClick(album, albumType) {
|
||||||
showToast('Showing previous results. Close this modal to start a new analysis.', 'info');
|
showToast('Showing previous results. Close this modal to start a new analysis.', 'info');
|
||||||
}
|
}
|
||||||
process.modalElement.style.display = 'flex';
|
process.modalElement.style.display = 'flex';
|
||||||
|
hideLoadingOverlay();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create virtual playlist and open modal
|
// Create virtual playlist and open modal
|
||||||
|
// Note: Don't hide loading overlay here - let the flow continue through to the modal
|
||||||
await createArtistAlbumVirtualPlaylist(album, albumType);
|
await createArtistAlbumVirtualPlaylist(album, albumType);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
hideLoadingOverlay();
|
||||||
console.error('❌ Error handling album click:', error);
|
console.error('❌ Error handling album click:', error);
|
||||||
showToast(`Error opening download modal: ${error.message}`, 'error');
|
showToast(`Error opening download modal: ${error.message}`, 'error');
|
||||||
}
|
}
|
||||||
|
|
@ -11963,8 +11969,7 @@ async function createArtistAlbumVirtualPlaylist(album, albumType) {
|
||||||
console.log(`🎵 Creating virtual playlist for: ${artist.name} - ${album.name}`);
|
console.log(`🎵 Creating virtual playlist for: ${artist.name} - ${album.name}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Show loading toast
|
// Loading overlay already shown by handleArtistAlbumClick
|
||||||
showToast(`Loading tracks for ${album.name}...`, 'info');
|
|
||||||
|
|
||||||
// Fetch album tracks from backend
|
// Fetch album tracks from backend
|
||||||
const response = await fetch(`/api/artist/${artist.id}/album/${album.id}/tracks`);
|
const response = await fetch(`/api/artist/${artist.id}/album/${album.id}/tracks`);
|
||||||
|
|
@ -11988,7 +11993,8 @@ async function createArtistAlbumVirtualPlaylist(album, albumType) {
|
||||||
const playlistName = `[${artist.name}] ${album.name}`;
|
const playlistName = `[${artist.name}] ${album.name}`;
|
||||||
|
|
||||||
// Open download missing tracks modal with formatted tracks
|
// Open download missing tracks modal with formatted tracks
|
||||||
await openDownloadMissingModalForArtistAlbum(virtualPlaylistId, playlistName, data.tracks, album, artist);
|
// Pass false for showLoadingOverlay since we already have one from handleArtistAlbumClick
|
||||||
|
await openDownloadMissingModalForArtistAlbum(virtualPlaylistId, playlistName, data.tracks, album, artist, false);
|
||||||
|
|
||||||
// Track this download for artist bubble management
|
// Track this download for artist bubble management
|
||||||
registerArtistDownload(artist, album, virtualPlaylistId, albumType);
|
registerArtistDownload(artist, album, virtualPlaylistId, albumType);
|
||||||
|
|
@ -12004,8 +12010,10 @@ async function createArtistAlbumVirtualPlaylist(album, albumType) {
|
||||||
* Open download missing tracks modal specifically for artist albums
|
* Open download missing tracks modal specifically for artist albums
|
||||||
* Similar to openDownloadMissingModalForYouTube but for artist albums
|
* Similar to openDownloadMissingModalForYouTube but for artist albums
|
||||||
*/
|
*/
|
||||||
async function openDownloadMissingModalForArtistAlbum(virtualPlaylistId, playlistName, spotifyTracks, album, artist) {
|
async function openDownloadMissingModalForArtistAlbum(virtualPlaylistId, playlistName, spotifyTracks, album, artist, showLoadingOverlayParam = true) {
|
||||||
showLoadingOverlay('Loading album...');
|
if (showLoadingOverlayParam) {
|
||||||
|
showLoadingOverlay('Loading album...');
|
||||||
|
}
|
||||||
// Check if a process is already active for this virtual playlist
|
// Check if a process is already active for this virtual playlist
|
||||||
if (activeDownloadProcesses[virtualPlaylistId]) {
|
if (activeDownloadProcesses[virtualPlaylistId]) {
|
||||||
console.log(`Modal for ${virtualPlaylistId} already exists. Showing it.`);
|
console.log(`Modal for ${virtualPlaylistId} already exists. Showing it.`);
|
||||||
|
|
@ -12015,6 +12023,9 @@ async function openDownloadMissingModalForArtistAlbum(virtualPlaylistId, playlis
|
||||||
showToast('Showing previous results. Close this modal to start a new analysis.', 'info');
|
showToast('Showing previous results. Close this modal to start a new analysis.', 'info');
|
||||||
}
|
}
|
||||||
process.modalElement.style.display = 'flex';
|
process.modalElement.style.display = 'flex';
|
||||||
|
if (showLoadingOverlayParam) {
|
||||||
|
hideLoadingOverlay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -14810,6 +14821,8 @@ function createReleaseCard(release) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showLoadingOverlay('Loading album...');
|
||||||
|
|
||||||
// For missing or incomplete releases, open wishlist modal
|
// For missing or incomplete releases, open wishlist modal
|
||||||
try {
|
try {
|
||||||
// Convert release object to album format expected by our function
|
// Convert release object to album format expected by our function
|
||||||
|
|
@ -14851,9 +14864,12 @@ function createReleaseCard(release) {
|
||||||
const albumType = release.type === 'single' ? 'singles' : 'albums';
|
const albumType = release.type === 'single' ? 'singles' : 'albums';
|
||||||
|
|
||||||
// Open the Add to Wishlist modal
|
// Open the Add to Wishlist modal
|
||||||
|
// Note: openAddToWishlistModal has its own loading overlay
|
||||||
|
hideLoadingOverlay();
|
||||||
await openAddToWishlistModal(albumData, currentArtist, data.tracks, albumType);
|
await openAddToWishlistModal(albumData, currentArtist, data.tracks, albumType);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
hideLoadingOverlay();
|
||||||
console.error('❌ Error handling release click:', error);
|
console.error('❌ Error handling release click:', error);
|
||||||
showToast(`Error opening wishlist modal: ${error.message}`, 'error');
|
showToast(`Error opening wishlist modal: ${error.message}`, 'error');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue