(modelData)
| 9424 | } |
| 9425 | |
| 9426 | if (index < 0 || index >= thumbnails.length) { |
| 9427 | throw new Error('Invalid thumbnail index'); |
| 9428 | } |
| 9429 | |
| 9430 | // Cannot delete the active (first) thumbnail |
| 9431 | if (index === 0) { |
| 9432 | throw new Error('Cannot delete the active thumbnail'); |
| 9433 | } |
| 9434 | |
| 9435 | // Remove the thumbnail at the specified index |
| 9436 | thumbnails.splice(index, 1); |
| 9437 | const updatedThumbnail = thumbnails.join('::'); |
| 9438 | await saveThumbnail(filePath, updatedThumbnail); |
| 9439 | |
| 9440 | // Send refresh event |
| 9441 | if (event && event.sender) { |
| 9442 | event.sender.send('thumbnail-deleted', { |
| 9443 | filePath: filePath, |
| 9444 | thumbnailCount: thumbnails.length |
| 9445 | }); |
| 9446 | } else if (isServerMode && global.broadcastEvent) { |
| 9447 | global.broadcastEvent('thumbnail-deleted', { |
| 9448 | filePath: filePath, |
| 9449 | thumbnailCount: thumbnails.length |
| 9450 | }); |
| 9451 | } |
| 9452 | |
| 9453 | return true; |
| 9454 | } catch (error) { |
| 9455 | console.error('Error deleting thumbnail:', error); |
| 9456 | throw error; |
| 9457 | } |
| 9458 | }); |
| 9459 | |
| 9460 | // Update the checkForUpdates function to track user's response |
| 9461 | async function checkForUpdates(isBeta = false) { |
| 9462 | try { |
| 9463 | // First check if we've already shown update dialog this session |
| 9464 | const versionCheckPerformed = db.prepare('SELECT value FROM settings WHERE key = ?').get('versionCheckPerformedOnStartup'); |
| 9465 | if (versionCheckPerformed && versionCheckPerformed.value === 'true') { |
| 9466 | console.log('Version check already performed this session, skipping'); |
| 9467 | return null; |
| 9468 | } |
| 9469 | |
| 9470 | return new Promise((resolve, reject) => { |
| 9471 | const versionUrl = isBeta ? |
| 9472 | 'https://printventory.com/beta.version' : |
| 9473 | 'https://printventory.com/public.version'; |
| 9474 | |
| 9475 | console.log('Main Process - Checking version URL:', versionUrl); |
| 9476 | |
| 9477 | https.get(versionUrl, (res) => { |
| 9478 | let data = ''; |
| 9479 | res.on('data', (chunk) => data += chunk); |
| 9480 | res.on('end', () => { |
| 9481 | const version = data.trim(); |
| 9482 | console.log('Main Process - Version check response:', version); |
| 9483 | // Validate version format (e.g., "0.6.0") |
no test coverage detected