(filePath)
| 3368 | renderProgressText.textContent = text || 'Generating thumbnails in background...'; |
| 3369 | if (stopButton) { |
| 3370 | stopButton.style.display = 'block'; |
| 3371 | stopButton.onclick = () => { |
| 3372 | window.electron.cancelServerThumbnailJob().catch((err) => { |
| 3373 | console.warn('Failed to cancel background thumbnail job:', err); |
| 3374 | }); |
| 3375 | renderProgressText.textContent = 'Stopping...'; |
| 3376 | stopButton.disabled = true; |
| 3377 | }; |
| 3378 | stopButton.disabled = false; |
| 3379 | } |
| 3380 | } |
| 3381 | |
| 3382 | function hideBackgroundThumbnailProgress() { |
| 3383 | const progressSection = document.getElementById('progress-section'); |
| 3384 | const renderProgressContainer = document.getElementById('render-progress-container'); |
| 3385 | const stopButton = document.getElementById('stop-thumbnail-generation'); |
| 3386 | if (stopButton) { |
| 3387 | stopButton.style.display = 'none'; |
| 3388 | stopButton.onclick = null; |
| 3389 | stopButton.disabled = false; |
| 3390 | } |
| 3391 | if (renderProgressContainer) renderProgressContainer.classList.add('hidden'); |
| 3392 | if (progressSection) { |
| 3393 | const progressContainer = document.getElementById('progress-container'); |
| 3394 | const scanVisible = progressContainer && !progressContainer.classList.contains('hidden'); |
| 3395 | if (!scanVisible) progressSection.classList.add('hidden'); |
| 3396 | } |
| 3397 | } |
| 3398 | |
| 3399 | async function refreshGridAfterBackgroundThumbnailJob() { |
| 3400 | try { |
| 3401 | if (typeof invalidatePrimaryThumbnailCache === 'function') { |
| 3402 | invalidatePrimaryThumbnailCache(); |
| 3403 | } |
| 3404 | const sortSelect = document.getElementById('sort-select'); |
| 3405 | if (typeof window.performCombinedSearch === 'function') { |
| 3406 | await window.performCombinedSearch(); |
| 3407 | } else if (typeof renderFiles === 'function') { |
| 3408 | const models = await window.electron.getAllModels(sortSelect ? sortSelect.value : 'date-desc', 0); |
| 3409 | await renderFiles(models); |
| 3410 | } |
| 3411 | } catch (err) { |
| 3412 | console.warn('Failed to refresh grid after background thumbnail job:', err); |
| 3413 | } |
| 3414 | } |
| 3415 | |
| 3416 | /** |
| 3417 | * Browser clients in server mode: start a server-side job and mirror progress locally. |
| 3418 | * Desktop / non-server: returns null so callers fall back to local generation. |
| 3419 | * Resolves early with { backgrounded: true } if the user moves the job to the sidebar. |
| 3420 | */ |
| 3421 | async function startAndWatchServerThumbnailJob(mode, title) { |
| 3422 | const serverMode = await window.electron.isServerMode().catch(() => false); |
| 3423 | const isWorker = await isServerThumbnailWorkerContext(); |
| 3424 | if (!serverMode || isWorker || typeof window.electron.startServerThumbnailJob !== 'function') { |
| 3425 | return null; |
| 3426 | } |
| 3427 |
no test coverage detected