version properly comparated

This commit is contained in:
MathieuG-P
2022-10-10 21:19:35 +02:00
parent c628d88957
commit bd40bf6519
3 changed files with 6 additions and 8 deletions
+3 -3
View File
@@ -11202,9 +11202,9 @@
}
},
"semver": {
"version": "7.3.7",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
"integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
"version": "7.3.8",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
"requires": {
"lru-cache": "^6.0.0"
}
+1
View File
@@ -243,6 +243,7 @@
"react-visibility-sensor": "^5.1.1",
"regedit": "^5.1.1",
"rxjs": "^7.5.6",
"semver": "^7.3.8",
"tailwind-scrollbar-hide": "^1.1.7",
"uuid": "^9.0.0"
},
+2 -5
View File
@@ -1,6 +1,7 @@
import { autoUpdater } from 'electron-updater';
import log from 'electron-log';
import { UtilsService } from './utils.service';
import { gt } from 'semver';
export class AutoUpdaterService {
private static instance: AutoUpdaterService;
@@ -24,7 +25,7 @@ export class AutoUpdaterService {
autoUpdater.checkForUpdates().then(info => {
const needUpdate = (() => {
if(!info || !info.updateInfo){ return false; }
if(autoUpdater.currentVersion.version === info.updateInfo.version){ return false; }
if(gt(autoUpdater.currentVersion.version, info.updateInfo.version)){ return false; }
return true;
})();
resolve(needUpdate)}
@@ -38,10 +39,6 @@ export class AutoUpdaterService {
autoUpdater.addListener("download-progress", info => {
this.utilsService.ipcSend("update-download-progress", {success: true, data: info.percent});
});
// const promise = new Promise<boolean>((resolve, reject) => {
// autoUpdater.addListener("update-downloaded", () => resolve(true));
// autoUpdater.addListener("error", () => reject(false))
// });
return autoUpdater.downloadUpdate().then(res => !!res && !!res.length);
}