MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / refreshMetadataList

Function refreshMetadataList

renderer.js:6781–6945  ·  view source on GitHub ↗
(type, searchTerm = '')

Source from the content-addressed store, hash-verified

6779
6780
6781
6782 // Remove the nested DOMContentLoaded listener and keep only one at the root level
6783 document.addEventListener('DOMContentLoaded', async () => {
6784 const tosAccepted = await checkTermsOfService();
6785 if (!tosAccepted) return;
6786
6787 // Initialize filters (without search)
6788 // Note: sort-select is handled by search.js via initializeCombinedSearch()
6789 const filterElements = [
6790 'designer-select',
6791 'license-select',
6792 'parent-select',
6793 'printed-select',
6794 'new-select',
6795 'tag-filter',
6796 'filetype-select' // Add this line
6797 ];
6798
6799 filterElements.forEach(elementId => {
6800 const element = document.getElementById(elementId);
6801 if (element) {
6802 element.addEventListener('change', handleFilterChange);
6803 }
6804 });
6805
6806 // Rest of initialization...
6807 await initializeTags();
6808 await populateTagFilter();
6809 initializeListButtons();
6810 });
6811
6812 // Remove the other DOMContentLoaded listener that's adding filter change handlers
6813
6814 await initializeTags();
6815 initializeListButtons();
6816
6817 // Update the tag filter event listener
6818 document.getElementById('tag-filter').addEventListener('change', async (event) => {
6819 const selectedTag = event.target.value;
6820 debugLog('Tag filter selected:', selectedTag);
6821
6822 if (!selectedTag) {
6823 // If no tag selected, show all models
6824 const models = await window.electron.getAllModels();
6825 return;
6826 }
6827
6828 try {
6829 // Get all models first
6830 const allModels = await window.electron.getAllModels();
6831 debugLog('Total models before filtering:', allModels.length);
6832
6833 // Filter models that have the selected tag
6834 const filteredModels = [];
6835 for (const model of allModels) {
6836 const modelTags = await window.electron.getModelTags(model.id);
6837 if (modelTags && modelTags.some(tag => tag.name === selectedTag)) {
6838 filteredModels.push(model);

Callers 3

renderer.jsFile · 0.85
initializeMetadataTabsFunction · 0.85
initializeMetadataSearchFunction · 0.85

Calls 3

refreshMetadataDropdownsFunction · 0.85
renderFilesFunction · 0.85
escapeHtmlFunction · 0.70

Tested by

no test coverage detected