(silent = false)
| 8184 | // Small delay to ensure database writes are flushed |
| 8185 | await new Promise(resolve => setTimeout(resolve, 150)); |
| 8186 | |
| 8187 | // Clear the model cache to force fresh data |
| 8188 | const container = document.querySelector('.file-grid'); |
| 8189 | if (container) { |
| 8190 | container.currentModels = null; // Clear cache to force re-render |
| 8191 | } |
| 8192 | |
| 8193 | // Refresh tag dropdowns in edit view |
| 8194 | await populateTagSelect('tag-select', 'model-tags'); |
| 8195 | await populateTagSelect('multi-tag-select', 'multi-tags'); |
| 8196 | await populateTagSelect('bundle-tag-select', 'bundle-tags'); |
| 8197 | |
| 8198 | // Refresh tag filter dropdown |
| 8199 | await populateTagFilter(); |
| 8200 | if (typeof populateRemoveTagSelect === 'function') { |
| 8201 | await populateRemoveTagSelect(); |
| 8202 | } |
| 8203 | if (typeof window.populateFilamentSelect === 'function') { |
| 8204 | await window.populateFilamentSelect('filament-select', 'model-filaments'); |
| 8205 | await window.populateFilamentSelect('multi-filament-select', 'multi-filaments'); |
| 8206 | } |
| 8207 | if (typeof window.populateFilamentFilter === 'function') { |
| 8208 | await window.populateFilamentFilter(); |
| 8209 | } |
| 8210 | |
| 8211 | // Refresh tag list in edit view if a model is currently being edited |
| 8212 | const currentModelPath = getCurrentModelFilePath() || currentModelDetailsPath; |
| 8213 | if (currentModelPath) { |
| 8214 | await loadModelTags(currentModelPath); |
| 8215 | if (typeof window.loadModelFilaments === 'function') { |
| 8216 | await window.loadModelFilaments(currentModelPath); |
| 8217 | } |
| 8218 | } |
| 8219 | |
| 8220 | // Force a full grid refresh to show updated tags on all model cards |
| 8221 | if (typeof window.performCombinedSearch === 'function') { |
| 8222 | await window.performCombinedSearch(); |
| 8223 | } else { |
| 8224 | // Fallback: Get current sort option and refresh the grid |
| 8225 | const sortSelect = document.getElementById('sort-select'); |
| 8226 | const models = await window.electron.getAllModels(sortSelect ? sortSelect.value : 'date-desc'); |
| 8227 | await renderFiles(models); |
| 8228 | } |
| 8229 | |
| 8230 | // Update all visible model elements to refresh their tags |
| 8231 | // This ensures tags are updated even if the grid doesn't fully re-render |
| 8232 | const allFileItems = document.querySelectorAll('.file-item'); |
| 8233 | for (const item of allFileItems) { |
| 8234 | const filePath = item.getAttribute('data-filepath') || item.dataset.filepath; |
| 8235 | if (filePath) { |
| 8236 | await updateModelElement(filePath); |
| 8237 | } |
| 8238 | } |
| 8239 | } catch (error) { |
| 8240 | console.error('Error refreshing UI after tag manager close:', error); |
| 8241 | } |
| 8242 | }); |
| 8243 | } |
no test coverage detected