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

Function handleFileClick

renderer.js:13336–13456  ·  view source on GitHub ↗
(event, filePath)

Source from the content-addressed store, hash-verified

13334 console.log('Thumbnail generation cancelled by user');
13335 };
13336
13337 // Add event listener to stop button
13338 stopButton.addEventListener('click', handleStopClick);
13339
13340 // When a background scan finds new models, we show the same "New Models" dialog as a foreground scan;
13341 // then skip the duplicate performCombinedSearch in finally (see skipBackgroundFinallyRefresh).
13342 let skipBackgroundFinallyRefresh = false;
13343
13344 try {
13345 if (background) {
13346 window.disableGridRefresh = true;
13347 console.log('Background scan: grid refresh disabled');
13348 }
13349 if (!background) {
13350 progressSection.classList.remove('hidden');
13351 progressContainer.classList.remove('hidden');
13352 renderProgressContainer.classList.remove('hidden');
13353 progressBar.style.width = '0%';
13354 progressText.textContent = 'Gathering files...';
13355 stopButton.style.display = 'block';
13356 }
13357
13358 // Use file extension to determine file type
13359 const isValidFile = (filename, size) => {
13360 const ext = filename.toLowerCase().split('.').pop();
13361 const maxSize = MAX_FILE_SIZE_MB * 1024 * 1024;
13362 return (ext === 'stl' || ext === '3mf') && size <= maxSize;
13363 };
13364
13365 // Store scan start time for filtering newly added models
13366 const scanStartTime = new Date().toISOString();
13367
13368 // Update the scan directory call to use the new validation and cancellation
13369 const scanOptions = isStlHomeScan ? { isStlHomeScan: true } : {};
13370 const scanResult = await window.electron.scanDirectory(directoryPath, scanOptions);
13371 const { files, totalFiles, newFilesCount, cancelScan } = scanResult || { files: [], totalFiles: 0, newFilesCount: 0 };
13372
13373 if (isCancelled) {
13374 if (cancelScan) cancelScan(); // Cancel the scan if possible
13375 throw new Error('Operation cancelled by user.');
13376 }
13377
13378 if (!files || files.length === 0) {
13379 if (!background) {
13380 progressBar.style.width = '100%';
13381 progressText.textContent = '';
13382 renderProgressBar.style.width = '100%';
13383 renderProgressText.textContent = '';
13384 }
13385 console.log('No files found in directory:', directoryPath);
13386 return; // Exit the function early instead of throwing error
13387 }
13388
13389 console.log('Scanned files:', totalFiles);
13390
13391 const allModels = await window.electron.getAllModels();
13392 const existingFiles = new Set(allModels.map(model => model.filePath));
13393 const existingThumbnails = new Map(allModels.map(model => [model.filePath, model.thumbnail]));

Callers 2

createModelItemFunction · 0.85

Calls 13

populateTagSelectFunction · 0.85
addToSelectedModelsFunction · 0.85
isInSelectedModelsFunction · 0.85
removeFromSelectedModelsFunction · 0.85
updateSelectedCountFunction · 0.85
showMultiEditPanelFunction · 0.85
exitMultiEditModeFunction · 0.85

Tested by

no test coverage detected