Tidy up cover search console logging and error toasts

This commit is contained in:
mikiher 2025-10-03 09:08:17 +03:00
parent 20de2ea388
commit 7e89b97a6d
2 changed files with 14 additions and 19 deletions

View File

@ -339,8 +339,6 @@ export default {
handleSearchResult(data) { handleSearchResult(data) {
if (data.requestId !== this.currentSearchRequestId) return if (data.requestId !== this.currentSearchRequestId) return
console.log(`[Cover Search] Received ${data.total} covers from ${data.provider}`)
// Add new covers to the list (avoiding duplicates) // Add new covers to the list (avoiding duplicates)
const newCovers = data.covers.filter((cover) => !this.coversFound.includes(cover)) const newCovers = data.covers.filter((cover) => !this.coversFound.includes(cover))
this.coversFound.push(...newCovers) this.coversFound.push(...newCovers)
@ -348,7 +346,6 @@ export default {
handleSearchComplete(data) { handleSearchComplete(data) {
if (data.requestId !== this.currentSearchRequestId) return if (data.requestId !== this.currentSearchRequestId) return
console.log('[Cover Search] Search completed')
this.searchInProgress = false this.searchInProgress = false
this.currentSearchRequestId = null this.currentSearchRequestId = null
}, },
@ -356,7 +353,7 @@ export default {
if (data.requestId !== this.currentSearchRequestId) return if (data.requestId !== this.currentSearchRequestId) return
console.error('[Cover Search] Search error:', data.error) console.error('[Cover Search] Search error:', data.error)
this.$toast.error(`Search failed: ${data.error}`) this.$toast.error(this.$strings.ToastCoverSearchFailed)
this.searchInProgress = false this.searchInProgress = false
this.currentSearchRequestId = null this.currentSearchRequestId = null
}, },
@ -364,34 +361,38 @@ export default {
if (data.requestId !== this.currentSearchRequestId) return if (data.requestId !== this.currentSearchRequestId) return
console.warn(`[Cover Search] Provider ${data.provider} failed:`, data.error) console.warn(`[Cover Search] Provider ${data.provider} failed:`, data.error)
// Don't show toast for individual provider failures, just log them
}, },
handleSearchCancelled(data) { handleSearchCancelled(data) {
if (data.requestId !== this.currentSearchRequestId) return if (data.requestId !== this.currentSearchRequestId) return
console.log('[Cover Search] Search cancelled')
this.searchInProgress = false this.searchInProgress = false
this.currentSearchRequestId = null this.currentSearchRequestId = null
}, },
handleSocketDisconnect() { handleSocketDisconnect() {
console.log('[Cover Search] Socket disconnected')
// If we were in the middle of a search, cancel it (server can't send results anymore) // If we were in the middle of a search, cancel it (server can't send results anymore)
if (this.searchInProgress && this.currentSearchRequestId) { if (this.searchInProgress && this.currentSearchRequestId) {
console.log('[Cover Search] Cancelling search due to socket disconnection')
this.searchInProgress = false this.searchInProgress = false
this.currentSearchRequestId = null this.currentSearchRequestId = null
this.$toast.warning('Search was interrupted by connection loss')
} }
}, },
cancelCurrentSearch() { cancelCurrentSearch() {
if (!this.currentSearchRequestId || !this.socket) return if (!this.currentSearchRequestId || !this.socket?.connected) {
console.error('[Cover Search] Socket not connected')
this.$toast.error(this.$strings.ToastConnectionNotAvailable)
return
}
console.log('[Cover Search] Cancelling search:', this.currentSearchRequestId)
this.socket.emit('cancel_cover_search', this.currentSearchRequestId) this.socket.emit('cancel_cover_search', this.currentSearchRequestId)
this.currentSearchRequestId = null this.currentSearchRequestId = null
this.searchInProgress = false this.searchInProgress = false
}, },
async submitSearchForm() { async submitSearchForm() {
if (!this.socket?.connected) {
console.error('[Cover Search] Socket not connected')
this.$toast.error(this.$strings.ToastConnectionNotAvailable)
return
}
// Cancel any existing search // Cancel any existing search
if (this.searchInProgress) { if (this.searchInProgress) {
this.cancelCurrentSearch() this.cancelCurrentSearch()
@ -400,12 +401,6 @@ export default {
// Store provider in local storage // Store provider in local storage
this.persistProvider() this.persistProvider()
if (!this.socket) {
console.error('[Cover Search] Socket not available')
this.$toast.error('Connection not available. Please refresh the page.')
return
}
// Setup socket listeners if not already done // Setup socket listeners if not already done
this.addSocketListeners() this.addSocketListeners()
@ -418,8 +413,6 @@ export default {
const requestId = this.generateRequestId() const requestId = this.generateRequestId()
this.currentSearchRequestId = requestId this.currentSearchRequestId = requestId
console.log('[Cover Search] Starting search:', requestId)
// Emit search request via WebSocket // Emit search request via WebSocket
this.socket.emit('search_covers', { this.socket.emit('search_covers', {
requestId, requestId,

View File

@ -1026,6 +1026,8 @@
"ToastCollectionItemsAddFailed": "Item(s) added to collection failed", "ToastCollectionItemsAddFailed": "Item(s) added to collection failed",
"ToastCollectionRemoveSuccess": "Collection removed", "ToastCollectionRemoveSuccess": "Collection removed",
"ToastCollectionUpdateSuccess": "Collection updated", "ToastCollectionUpdateSuccess": "Collection updated",
"ToastConnectionNotAvailable": "Connection not available. Please try again later",
"ToastCoverSearchFailed": "Cover search failed",
"ToastCoverUpdateFailed": "Cover update failed", "ToastCoverUpdateFailed": "Cover update failed",
"ToastDateTimeInvalidOrIncomplete": "Date and time is invalid or incomplete", "ToastDateTimeInvalidOrIncomplete": "Date and time is invalid or incomplete",
"ToastDeleteFileFailed": "Failed to delete file", "ToastDeleteFileFailed": "Failed to delete file",