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

Function navigateThumbnail

renderer.js:17458–17511  ·  view source on GitHub ↗
(direction)

Source from the content-addressed store, hash-verified

17456}
17457
17458// Add implementation of autoSaveMultipleModels function
17459async function autoSaveMultipleModels(field, value, options = {}) {
17460 try {
17461 // No models selected
17462 if (selectedModels.size === 0) {
17463 console.warn('No models selected for autoSaveMultipleModels');
17464 return false; // Indicate failure/no-op
17465 }
17466
17467 // Handle designer field default value (will be reapplied next)
17468 if (field === 'designer' && !value) {
17469 value = 'Unknown';
17470 }
17471
17472 // Create a copy of selectedModels to avoid issues if the set changes during iteration
17473 const modelsToUpdate = Array.from(selectedModels);
17474 console.log(`autoSaveMultipleModels: Updating ${modelsToUpdate.length} models for field ${field}`);
17475
17476 // Load all models in parallel for better performance
17477 const modelLoadPromises = modelsToUpdate.map(async (filePath, index) => {
17478 try {
17479 console.log(`[${index}] Loading model: ${filePath}`);
17480 const model = await window.electron.getModel(filePath);
17481 if (model) {
17482 console.log(`[${index}] Successfully loaded model: ${filePath}`);
17483 return { filePath, model };
17484 } else {
17485 console.warn(`[${index}] Could not find model for ${filePath} during autoSaveMultipleModels`);
17486 return null;
17487 }
17488 } catch (error) {
17489 console.error(`[${index}] Error loading model ${filePath} in autoSaveMultipleModels:`, error);
17490 return null;
17491 }
17492 });
17493
17494 // Wait for all models to load in parallel
17495 const loadedModels = await Promise.all(modelLoadPromises);
17496 console.log(`Loaded ${loadedModels.length} models, ${loadedModels.filter(r => r !== null).length} successful`);
17497
17498 // Filter out null results and prepare updates
17499 const modelUpdates = [];
17500 for (let i = 0; i < loadedModels.length; i++) {
17501 const result = loadedModels[i];
17502 if (result) {
17503 const { filePath, model } = result;
17504 console.log(`[${i}] Processing model update for: ${filePath}`);
17505 // Special handling for tags - MERGE or REPLACE based on options
17506 if (field === 'tags') {
17507 const newTags = Array.isArray(value) ? value : [];
17508 if (options.replaceTags) {
17509 // Replace tags completely (used when removing tags)
17510 model.tags = newTags.sort();
17511 console.log(`[${i}] Replacing tags with: ${newTags.join(', ')}`);
17512 } else {
17513 // Merge tags (used when adding tags)
17514 const existingTags = Array.isArray(model.tags) ? model.tags : [];

Callers 2

createModelItemFunction · 0.85

Calls 2

parseMethod · 0.80
parseThumbnailsFunction · 0.70

Tested by

no test coverage detected