(label, items)
| 3596 | if (container?.currentModels) { |
| 3597 | const modelIndex = container.currentModels.findIndex( |
| 3598 | (m) => normalizePathForComparison(m.filePath) === normalizedPath |
| 3599 | ); |
| 3600 | if (modelIndex >= 0) container.currentModels[modelIndex] = { ...updatedModel }; |
| 3601 | } |
| 3602 | fileItem.remove(); |
| 3603 | if (container?.renderVisibleItemsFn) container.renderVisibleItemsFn(); |
| 3604 | return; |
| 3605 | } |
| 3606 | return; |
| 3607 | } |
| 3608 | |
| 3609 | const updatedModel = await window.electron.getModel(filePath); |
| 3610 | if (!updatedModel) return; |
| 3611 | |
| 3612 | const container = document.querySelector('.file-grid'); |
| 3613 | for (const fileItem of document.querySelectorAll('.file-item')) { |
| 3614 | const itemPath = fileItem.getAttribute('data-filepath') || fileItem.dataset.filepath; |
| 3615 | if (normalizePathForComparison(itemPath) !== normalizedPath) continue; |
| 3616 | if (container?.currentModels) { |
| 3617 | const modelIndex = container.currentModels.findIndex( |
| 3618 | (m) => normalizePathForComparison(m.filePath) === normalizedPath |
| 3619 | ); |
| 3620 | if (modelIndex >= 0) container.currentModels[modelIndex] = { ...updatedModel }; |
| 3621 | } |
| 3622 | fileItem.remove(); |
| 3623 | if (container?.renderVisibleItemsFn) container.renderVisibleItemsFn(); |
| 3624 | return; |
| 3625 | } |
| 3626 | |
| 3627 | if (typeof window.performCombinedSearch === 'function') { |
| 3628 | await window.performCombinedSearch(); |
| 3629 | } else { |
| 3630 | const sortSelect = document.getElementById('sort-select'); |
| 3631 | const models = await window.electron.getAllModels(sortSelect ? sortSelect.value : 'date-desc'); |
| 3632 | if (typeof renderFiles === 'function') await renderFiles(models); |
| 3633 | } |
| 3634 | } catch (err) { |
| 3635 | console.error('Error refreshing grid after active thumbnail change:', err); |
| 3636 | if (typeof window.performCombinedSearch === 'function') { |
| 3637 | await window.performCombinedSearch(); |
| 3638 | } |
| 3639 | } |
| 3640 | } |
| 3641 | |
| 3642 | // Function to show manage thumbnails modal |
| 3643 | async function showManageThumbnailsModal(filePath) { |
| 3644 | const dialog = document.getElementById('manage-thumbnails-dialog'); |
| 3645 | const grid = document.getElementById('thumbnails-grid'); |
| 3646 | |
| 3647 | if (!dialog || !grid) { |
| 3648 | throw new Error('Manage thumbnails dialog elements not found'); |
| 3649 | } |
| 3650 | const title = dialog.querySelector('h3'); |
| 3651 | const desc = dialog.querySelector('.form-group p'); |
| 3652 | if (title) title.textContent = 'Manage Thumbnails'; |
| 3653 | if (desc) desc.textContent = 'Select a thumbnail to set it as active, or delete thumbnails (the active thumbnail cannot be deleted).'; |
| 3654 | |
| 3655 | if (!dialog._manageThumbnailsCloseListenerAttached) { |
no outgoing calls
no test coverage detected