From 86351d17362148168507958d33aad6111fd634aa Mon Sep 17 00:00:00 2001 From: jobevers Date: Mon, 20 Feb 2017 12:56:15 -0600 Subject: [PATCH] Improve updates download - create progress bar modal - trigger app shutdown on successful download - move update url logic to the website --- js/app.js | 30 ++++++++++++++++-------------- package.json | 1 + 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/js/app.js b/js/app.js index dd3c86e74..9b7348149 100644 --- a/js/app.js +++ b/js/app.js @@ -1,4 +1,6 @@ import React from 'react'; +import {Line} from 'rc-progress'; + import lbry from './lbry.js'; import SettingsPage from './page/settings.js'; import HelpPage from './page/help.js'; @@ -20,9 +22,10 @@ import Modal from './component/modal.js'; import {Link} from './component/link.js'; -const remote = require('electron').remote; +const {remote, ipcRenderer} = require('electron'); const {download} = remote.require('electron-dl'); +const UPDATE_URL = 'https://lbry.io/get/latest'; var App = React.createClass({ _error_key_labels: { @@ -48,8 +51,8 @@ var App = React.createClass({ pageArgs: typeof val !== 'undefined' ? val : null, errorInfo: null, modal: null, - updateUrl: null, isOldOSX: null, + downloadProgress: null, }; }, componentWillMount: function() { @@ -65,25 +68,15 @@ var App = React.createClass({ lbry.getVersionInfo((versionInfo) => { 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.msi'; - } else { - var updateUrl = 'https://lbry.io/get'; } - this.setState({ modal: 'upgrade', isOldOSX: isOldOSX, - updateUrl: versionInfo.lbrynet_update_url, }) }); }); @@ -108,8 +101,12 @@ var App = React.createClass({ // some indication that the download is happening // TODO: calling lbry.stop() ends up displaying the "daemon // unexpectedly stopped" page. Have a better way of shutting down - download(remote.getCurrentWindow(), this.state.updateUrl, {saveAs: true}) - .then(dl => lbry.stop()) + let options = { + onProgress: (p) => this.setState({downloadProgress: Math.round(p * 100)}), + } + download(remote.getCurrentWindow(), UPDATE_URL, options) + .then(dl => ipcRenderer.send('shutdown')); + this.setState({modal: 'downloading'}); }, handleSkipClicked: function() { sessionStorage.setItem('upgradeSkipped', true); @@ -222,6 +219,11 @@ var App = React.createClass({ : null} + // TODO: have color refence css color-primary + + Downloading Update: {this.state.downloadProgress}% Complete + +

Error

diff --git a/package.json b/package.json index d9d719fc7..70b849611 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "clamp-js-main": "^0.11.1", "mediaelement": "^2.23.4", "node-sass": "^3.8.0", + "rc-progress": "^2.0.6", "react": "^15.4.0", "react-dom": "^15.4.0", "react-modal": "^1.5.2",