Fix update popup showing for same version - add version comparison checks

This commit is contained in:
chasem-dev
2026-01-22 10:36:18 -05:00
parent d7a904c641
commit ce052add0d
3 changed files with 55 additions and 12 deletions

View File

@@ -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;

View File

@@ -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
});
}
});

37
main.js
View File

@@ -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