Improve updates download
- create progress bar modal - trigger app shutdown on successful download - move update url logic to the website
This commit is contained in:
parent
321fbfbc17
commit
27b85e2301
2 changed files with 27 additions and 12 deletions
38
js/app.js
38
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';
|
||||
|
@ -19,6 +21,12 @@ import Header from './component/header.js';
|
|||
import Modal from './component/modal.js';
|
||||
import {Link} from './component/link.js';
|
||||
|
||||
|
||||
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: {
|
||||
connectionString: 'API connection string',
|
||||
|
@ -43,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() {
|
||||
|
@ -60,21 +68,12 @@ 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,
|
||||
|
@ -97,8 +96,18 @@ var App = React.createClass({
|
|||
});
|
||||
},
|
||||
handleUpgradeClicked: function() {
|
||||
lbry.stop();
|
||||
window.location = this.state.updateUrl;
|
||||
// TODO: create a callback for onProgress and have the UI
|
||||
// show download progress
|
||||
// TODO: remove the saveAs popup. Thats just me being lazy and having
|
||||
// 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
|
||||
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);
|
||||
|
@ -211,6 +220,11 @@ var App = React.createClass({
|
|||
: null}
|
||||
|
||||
</Modal>
|
||||
// TODO: have color refence css color-primary
|
||||
<Modal isOpen={this.state.modal == 'downloading'} contentLabel="Downloading Update" type="custom">
|
||||
Downloading Update: {this.state.downloadProgress}% Complete
|
||||
<Line percent={this.state.downloadProgress} strokeWidth="4"/>
|
||||
</Modal>
|
||||
<Modal isOpen={this.state.modal == 'error'} contentLabel="Error" type="custom"
|
||||
className="error-modal" overlayClassName="error-modal-overlay" >
|
||||
<h3 className="modal__header">Error</h3>
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue