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

Function refreshGridModelAfterManageThumbnailsActiveChange

renderer.js:3302–3367  ·  view source on GitHub ↗

After reordering the default thumbnail, sync the virtual grid cell (same approach as thumbnail-deleted IPC).

(filePath)

Source from the content-addressed store, hash-verified

3300 await window.electron.showMessage('Warning', failedMsg);
3301 }, 600);
3302 } else {
3303 // Show non-blocking notification for partial failures
3304 console.warn(failedMsg);
3305 }
3306 }
3307 };
3308
3309 // Listen for completion event
3310 window.electron.onHashGenerationComplete(completionListener);
3311
3312 // Set up the listener (works in both normal and server mode)
3313 window.electron.onHashGenerationProgress(progressListener);
3314
3315 // Check if hash generation is already running before starting
3316 const isAlreadyRunning = await window.electron.isGeneratingHashes();
3317 if (isAlreadyRunning) {
3318 console.log('Hash generation already in progress, attaching to existing process');
3319 // Don't start a new process, just attach to the existing one
3320 // The progress listener is already set up above, so it will receive updates
3321 // Update the dialog message to indicate we're joining an existing process
3322 const dialogContent = progressDialog.querySelector('p');
3323 if (dialogContent) {
3324 dialogContent.textContent = 'Hash generation is already running in the background. Progress will be shown here.';
3325 }
3326 // Don't call generateMissingHashes() - just wait for progress updates
3327 return; // Exit early, progress listener will handle completion
3328 }
3329
3330 // Start hash generation
3331 try {
3332 const result = await window.electron.generateMissingHashes();
3333
3334 // Check if it's already running (shouldn't happen after the check above, but handle it)
3335 if (result && result.alreadyRunning) {
3336 console.log('Hash generation was already running, attached to existing process');
3337 // Progress listener is already set up, just wait for updates
3338 return;
3339 }
3340
3341 // Check if all hashes failed
3342 if (result && result.failed === result.total && result.total > 0) {
3343 // All hashes failed - error dialog will be shown by completion listener
3344 // Reset flags
3345 isHashDialogShowing = false;
3346 isCheckingForHashes = false;
3347 // Close progress dialog
3348 progressDialog.close();
3349 progressDialog.remove();
3350 return;
3351 }
3352 // If some or all succeeded, the completion listener will handle the dialog closing
3353 } catch (error) {
3354 console.error('Error generating hashes:', error);
3355 // Reset flags on error
3356 isHashDialogShowing = false;
3357 isCheckingForHashes = false;
3358 // Close progress dialog
3359 progressDialog.close();

Callers 1

Calls 2

renderFilesFunction · 0.85

Tested by

no test coverage detected