Update script.js
This commit is contained in:
parent
3dba6f97c4
commit
e62800f4b5
1 changed files with 30 additions and 8 deletions
|
|
@ -75,6 +75,7 @@ let artistDownloadModalOpen = false; // Track if artist download modal is open
|
||||||
let downloadsUpdateTimeout = null; // Debounce downloads section updates
|
let downloadsUpdateTimeout = null; // Debounce downloads section updates
|
||||||
let artistsSearchTimeout = null;
|
let artistsSearchTimeout = null;
|
||||||
let artistsSearchController = null;
|
let artistsSearchController = null;
|
||||||
|
let artistCompletionController = null; // Track ongoing completion check to cancel when navigating away
|
||||||
|
|
||||||
// --- Wishlist Modal Persistence State Management ---
|
// --- Wishlist Modal Persistence State Management ---
|
||||||
const WishlistModalState = {
|
const WishlistModalState = {
|
||||||
|
|
@ -14997,6 +14998,13 @@ function createArtistCardHTML(artist) {
|
||||||
async function selectArtistForDetail(artist) {
|
async function selectArtistForDetail(artist) {
|
||||||
console.log(`🎤 Selected artist: ${artist.name}`);
|
console.log(`🎤 Selected artist: ${artist.name}`);
|
||||||
|
|
||||||
|
// Cancel any ongoing completion check from previous artist
|
||||||
|
if (artistCompletionController) {
|
||||||
|
console.log('⏹️ Canceling previous artist completion check');
|
||||||
|
artistCompletionController.abort();
|
||||||
|
artistCompletionController = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Update state
|
// Update state
|
||||||
artistsPageState.selectedArtist = artist;
|
artistsPageState.selectedArtist = artist;
|
||||||
artistsPageState.currentView = 'detail';
|
artistsPageState.currentView = 'detail';
|
||||||
|
|
@ -15414,7 +15422,8 @@ async function checkDiscographyCompletion(artistId, discography) {
|
||||||
console.log(`🔍 Starting streaming completion check for artist: ${artistId}`);
|
console.log(`🔍 Starting streaming completion check for artist: ${artistId}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Use fetch with streaming response (Server-Sent Events)
|
// Create new abort controller for this completion check
|
||||||
|
artistCompletionController = new AbortController();
|
||||||
|
|
||||||
// Use fetch with streaming response
|
// Use fetch with streaming response
|
||||||
const response = await fetch(`/api/artist/${artistId}/completion-stream`, {
|
const response = await fetch(`/api/artist/${artistId}/completion-stream`, {
|
||||||
|
|
@ -15426,7 +15435,8 @@ async function checkDiscographyCompletion(artistId, discography) {
|
||||||
discography: discography,
|
discography: discography,
|
||||||
artist_name: artistsPageState.selectedArtist?.name || 'Unknown Artist',
|
artist_name: artistsPageState.selectedArtist?.name || 'Unknown Artist',
|
||||||
test_mode: window.location.search.includes('test=true')
|
test_mode: window.location.search.includes('test=true')
|
||||||
})
|
}),
|
||||||
|
signal: artistCompletionController.signal
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
|
@ -15456,9 +15466,21 @@ async function checkDiscographyCompletion(artistId, discography) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear the controller when done
|
||||||
|
artistCompletionController = null;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// Don't show error if it was aborted (user navigated away)
|
||||||
|
if (error.name === 'AbortError') {
|
||||||
|
console.log('⏹️ Completion check aborted (user navigated to new artist)');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
console.error('❌ Failed to check completion status:', error);
|
console.error('❌ Failed to check completion status:', error);
|
||||||
showCompletionError();
|
showCompletionError();
|
||||||
|
} finally {
|
||||||
|
// Always clear the controller
|
||||||
|
artistCompletionController = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue