Fixed update check
authorRemixDev <deezloaderremix@gmail.com>
Thu, 21 Feb 2019 12:51:07 +0000 (13:51 +0100)
committerRemixDev <deezloaderremix@gmail.com>
Thu, 21 Feb 2019 12:51:07 +0000 (13:51 +0100)
app/app.js

index fb2e064ed8477539b30da359490b39a1dad998a6..31b6112a5543e12ad728733c7f648265823fef56 100644 (file)
@@ -84,13 +84,13 @@ io.sockets.on('connection', function (s) {
        })
        .then(body=>{
                logger.info("Checking for updates")
-               let [currentVersion_MAJOR, currentVersion_MINOR, currentVersion_PATCH] = package.version.split(".")
-               let [lastVersion_MAJOR, lastVersion_MINOR, lastVersion_PATCH] = body.version.split(".")
+               let [currentVersion_MAJOR, currentVersion_MINOR, currentVersion_PATCH] = package.version.split(".").map(x=>parseInt(x))
+               let [lastVersion_MAJOR, lastVersion_MINOR, lastVersion_PATCH] = body.version.split(".").map(x=>parseInt(x))
                if (
-                       parseInt(lastVersion_MAJOR) > parseInt(currentVersion_MAJOR) ||
-                       parseInt(lastVersion_MINOR) > parseInt(currentVersion_MINOR) ||
-                       parseInt(lastVersion_PATCH) > parseInt(currentVersion_PATCH))
-               {
+                       lastVersion_MAJOR>currentVersion_MAJOR ||
+                       lastVersion_MAJOR==currentVersion_MAJOR && lastVersion_MINOR>currentVersion_MINOR ||
+                       lastVersion_MAJOR==currentVersion_MAJOR && lastVersion_MINOR==currentVersion_MINOR && lastVersion_PATCH>currentVersion_PATCH
+               ){
                        logger.info("Update Available")
                        s.emit("message", {title: `Version ${lastVersion_MAJOR}.${lastVersion_MINOR}.${lastVersion_PATCH} is available!`, msg: body.changelog})
                }