From 052eef5f81556cf0f50593988b251312aa1911f4 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 22 Mar 2017 06:55:16 -0400 Subject: [PATCH] Light refactoring of upgrade process - Use Node instead of lbrynet to get platform info - Factor out code that picks the download URI into its own function - Remove out-of-date code for checking old versions of MacOS --- ui/js/app.js | 59 ++++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/ui/js/app.js b/ui/js/app.js index 6ce99b9ba..906802bb5 100644 --- a/ui/js/app.js +++ b/ui/js/app.js @@ -43,6 +43,17 @@ var App = React.createClass({ _upgradeDownloadItem: null, _version: null, + getUpdateUrl: function() { + console.log('os.platform is', os.platform()); + switch (os.platform()) { + case 'darwin': + return 'https://lbry.io/get/lbry.dmg'; + case 'linux': + return 'https://lbry.io/get/lbry.deb'; + case 'win32': + return 'https://lbry.io/get/lbry.exe'; // should now be msi + } + }, // Temporary workaround since electron-dl throws errors when you try to get the filename getUpgradeFilename: function() { if (os.platform() == 'darwin') { @@ -67,8 +78,6 @@ var App = React.createClass({ pageArgs: typeof val !== 'undefined' ? val : null, errorInfo: null, modal: null, - updateUrl: null, - isOldOSX: null, downloadProgress: null, downloadComplete: false, }; @@ -91,38 +100,20 @@ var App = React.createClass({ } }); - lbry.checkNewVersionAvailable((isAvailable) => { - if (!isAvailable || sessionStorage.getItem('upgradeSkipped')) { - return; - } - - lbry.getVersionInfo((versionInfo) => { - this._version = versionInfo.lbrynet_version; // temp for building upgrade filename - - var isOldOSX = false; - if (versionInfo.os_system == 'Darwin') { - var updateUrl = 'https://lbry.io/get/lbry.dmg'; - - var maj, min, patch; - [maj, min, patch] = versionInfo.lbrynet_version.split('.'); - if (maj == 0 && min <= 2 && patch <= 2) { - isOldOSX = true; - } - } else if (versionInfo.os_system == 'Linux') { - var updateUrl = 'https://lbry.io/get/lbry.deb'; - } else if (versionInfo.os_system == 'Windows') { - var updateUrl = 'https://lbry.io/get/lbry.exe'; - } else { - var updateUrl = 'https://lbry.io/get'; + if (!sessionStorage.getItem('upgradeSkipped')) { + lbry.checkNewVersionAvailable(({isAvailable}) => { + if (!isAvailable) { + return; } - this.setState({ - modal: 'upgrade', - isOldOSX: isOldOSX, - updateUrl: updateUrl, - }) + lbry.getVersionInfo((versionInfo) => { + this._version = versionInfo.lbrynet_version; + this.setState({ + modal: 'upgrade', + }); + }); }); - }); + } }, openDrawer: function() { sessionStorage.setItem('drawerOpen', true); @@ -288,11 +279,7 @@ var App = React.createClass({ -

Your version of LBRY is out of date and may be unreliable or insecure.

- {this.state.isOldOSX - ?

Before installing the new version, make sure to exit LBRY. If you started the app, click the LBRY icon in your status bar and choose "Quit."

- : null} - + Your version of LBRY is out of date and may be unreliable or insecure.
Downloading Update{this.state.downloadProgress ? `: ${this.state.downloadProgress}%` : null}