From f8c0382db0e2aa251c68ce8926d15ca75801b3a8 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Tue, 12 Apr 2016 06:30:25 -0400 Subject: [PATCH] If user has old version, redirect them to lbry.io/[os] to upgrade The OS checking is ugly, but once we have an "upgrade" page on lbry.io we'll change it to point there --- js/app.js | 9 +++++++++ js/lbry.js | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/js/app.js b/js/app.js index 58d4d6baf..309846633 100644 --- a/js/app.js +++ b/js/app.js @@ -9,6 +9,15 @@ var App = React.createClass({ viewingPage: window.location.search === '?settings' ? 'settings' : 'home' } }, + componentWillMount: function() { + lbry.checkNewVersionAvailable(function(isAvailable) { + if (isAvailable) { + alert("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."); + window.location = "http://www.lbry.io/" + (navigator.userAgent.indexOf('Mac OS X') != -1 ? 'osx' : 'linux'); + } + }); + }, componentDidMount: function() { lbry.getStartNotice(function(notice) { if (notice) { diff --git a/js/lbry.js b/js/lbry.js index 314825a8b..167b8c2a4 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -91,6 +91,18 @@ lbry.search = function(query, callback) lbry.call("search_nametrie", { "search": query }, 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); + }, function(err) { + if (err.fault == 'NoSuchFunction') { + // If it's not available, we're definitely in an old version + callback(true); + } + }); +} + //utilities lbry.formatCredits = function(amount, precision) {