From 5f5e3ae5c6a38e7625a5ae33e44cb9190e452b6f Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Mon, 30 May 2016 09:43:34 -0400 Subject: [PATCH] Version check/upgrade improvements - Upgrading is now optional - Move version comparison logic into JS (Jack took it out of the daemon) --- js/app.js | 41 ++++++++++++++++++++++------------------- js/lbry.js | 14 ++++++++++---- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/js/app.js b/js/app.js index 99d89f991..e44359b9c 100644 --- a/js/app.js +++ b/js/app.js @@ -17,26 +17,29 @@ var App = React.createClass({ }, componentWillMount: function() { lbry.checkNewVersionAvailable(function(isAvailable) { - if (isAvailable) { - var message = "The version of LBRY you're using is not up to date.\n\n" + - "You'll now be taken to lbry.io, where you can download the latest version."; - - lbry.getVersionInfo(function(versionInfo) { - var maj, min, patch; - [maj, min, patch] = versionInfo.lbrynet_version.split('.'); - - if (versionInfo.os_system == 'Darwin' && maj == 0 && min <= 2 && patch <= 2) { - // On OS X with version <= 0.2.2, we need to notify user to close manually close LBRY - message += "\n\nBefore installing the new version, make sure to exit LBRY, if you started the app " + - "click that LBRY icon in your status bar and choose \"Quit.\""; - } else { - lbry.stop(); - } - - alert(message); - window.location = "http://www.lbry.io/" + (versionInfo.os_system == 'Darwin' ? 'osx' : 'linux'); - }); + if (!isAvailable) { + return; } + + var message = 'The version of LBRY you\'re using is not up to date.\n\n' + + 'Would you like to visit lbry.io now to get the latest version?'; + + lbry.getVersionInfo(function(versionInfo) { + var maj, min, patch; + [maj, min, patch] = versionInfo.lbrynet_version.split('.'); + + if (versionInfo.os_system == 'Darwin' && maj == 0 && min <= 2 && patch <= 2) { + // On OS X with version <= 0.2.2, we need to notify user to close manually close LBRY + message += '\n\nBefore installing the new version, make sure to exit LBRY, if you started the app ' + + 'click that LBRY icon in your status bar and choose "Quit."'; + } else { + lbry.stop(); + } + + if (window.confirm(message)) { + window.location = 'http://www.lbry.io/get'; + }; + }); }); }, render: function() { diff --git a/js/lbry.js b/js/lbry.js index 2afc1e607..b410f616b 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -135,12 +135,18 @@ lbry.getVersionInfo = function(callback) { }; lbry.checkNewVersionAvailable = function(callback) { - lbry.call('version', {}, function() { - // If the "version" method is available, we have a daemon new enough to do version checking - lbry.call('check_for_new_version', {}, callback); + lbry.call('version', {}, function(versionInfo) { + var maj, min, patch; + [maj, min, patch] = versionInfo.lbrynet_version.split('.'); + + var remoteMaj, remoteMin, remotePatch; + [remoteMaj, remoteMin, remotePatch] = versionInfo.remote_lbrynet.split('.'); + + var newVersionAvailable = (maj < remoteMaj || min < remoteMin || patch < remotePatch); + callback(newVersionAvailable); }, function(err) { if (err.fault == 'NoSuchFunction') { - // If it's not available, we're definitely in an old version + // Really old daemon that can't report a version callback(true); } });