diff --git a/GUI/js/update.js b/GUI/js/update.js index 9f78f80..9d34a4e 100644 --- a/GUI/js/update.js +++ b/GUI/js/update.js @@ -335,7 +335,12 @@ class ClientUpdateManager { async checkForUpdatesOnDemand() { try { const updateInfo = await window.electronAPI.checkForUpdates(); - if (updateInfo.updateAvailable) { + + // Double-check that versions are actually different before showing popup + if (updateInfo.updateAvailable && + updateInfo.newVersion && + updateInfo.currentVersion && + updateInfo.newVersion !== updateInfo.currentVersion) { this.showUpdatePopup(updateInfo); } return updateInfo; diff --git a/backend/appUpdater.js b/backend/appUpdater.js index cc87efd..98d1f65 100644 --- a/backend/appUpdater.js +++ b/backend/appUpdater.js @@ -43,23 +43,32 @@ class AppUpdater { autoUpdater.on('update-available', (info) => { console.log('Update available:', info.version); + const currentVersion = app.getVersion(); + const newVersion = info.version; + + // Only proceed if the new version is actually different from current + if (newVersion === currentVersion) { + console.log('Update version matches current version, ignoring update-available event'); + return; + } + this.updateAvailable = true; - this.updateVersion = info.version; + this.updateVersion = newVersion; this.autoUpdateAvailable = true; // Reset flag when new update is available if (this.mainWindow && !this.mainWindow.isDestroyed()) { this.mainWindow.webContents.send('update-available', { - version: info.version, - newVersion: info.version, - currentVersion: app.getVersion(), + version: newVersion, + newVersion: newVersion, + currentVersion: currentVersion, releaseName: info.releaseName, releaseNotes: info.releaseNotes }); // Also send to the old popup handler for compatibility this.mainWindow.webContents.send('show-update-popup', { - currentVersion: app.getVersion(), - newVersion: info.version, - version: info.version + currentVersion: currentVersion, + newVersion: newVersion, + version: newVersion }); } }); diff --git a/main.js b/main.js index 912abe2..3e1b914 100644 --- a/main.js +++ b/main.js @@ -728,11 +728,19 @@ ipcMain.handle('check-for-updates', async () => { try { if (appUpdater) { const result = await appUpdater.checkForUpdates(); + const currentVersion = app.getVersion(); + const remoteVersion = result?.updateInfo?.version; + + // Only show update if remote version is actually newer than current + const updateAvailable = remoteVersion && + remoteVersion !== currentVersion && + isVersionNewer(remoteVersion, currentVersion); + return { - updateAvailable: result?.updateInfo ? true : false, - version: result?.updateInfo?.version, - newVersion: result?.updateInfo?.version, - currentVersion: app.getVersion() + updateAvailable: updateAvailable, + version: remoteVersion, + newVersion: remoteVersion, + currentVersion: currentVersion }; } return { updateAvailable: false, error: 'AppUpdater not initialized' }; @@ -742,6 +750,27 @@ ipcMain.handle('check-for-updates', async () => { } }); +// Helper function to compare semantic versions +function isVersionNewer(version1, version2) { + // Simple semantic version comparison + // Remove any non-numeric suffixes for comparison + const v1Parts = version1.replace(/[^0-9.]/g, '').split('.').map(Number); + const v2Parts = version2.replace(/[^0-9.]/g, '').split('.').map(Number); + + // Pad arrays to same length + const maxLength = Math.max(v1Parts.length, v2Parts.length); + while (v1Parts.length < maxLength) v1Parts.push(0); + while (v2Parts.length < maxLength) v2Parts.push(0); + + // Compare each part + for (let i = 0; i < maxLength; i++) { + if (v1Parts[i] > v2Parts[i]) return true; + if (v1Parts[i] < v2Parts[i]) return false; + } + + return false; // Versions are equal +} + ipcMain.handle('open-download-page', async () => { try { // Open GitHub releases page