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
This commit is contained in:
parent
f51b720e05
commit
052eef5f81
1 changed files with 23 additions and 36 deletions
59
ui/js/app.js
59
ui/js/app.js
|
@ -43,6 +43,17 @@ var App = React.createClass({
|
||||||
_upgradeDownloadItem: null,
|
_upgradeDownloadItem: null,
|
||||||
_version: 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
|
// Temporary workaround since electron-dl throws errors when you try to get the filename
|
||||||
getUpgradeFilename: function() {
|
getUpgradeFilename: function() {
|
||||||
if (os.platform() == 'darwin') {
|
if (os.platform() == 'darwin') {
|
||||||
|
@ -67,8 +78,6 @@ var App = React.createClass({
|
||||||
pageArgs: typeof val !== 'undefined' ? val : null,
|
pageArgs: typeof val !== 'undefined' ? val : null,
|
||||||
errorInfo: null,
|
errorInfo: null,
|
||||||
modal: null,
|
modal: null,
|
||||||
updateUrl: null,
|
|
||||||
isOldOSX: null,
|
|
||||||
downloadProgress: null,
|
downloadProgress: null,
|
||||||
downloadComplete: false,
|
downloadComplete: false,
|
||||||
};
|
};
|
||||||
|
@ -91,38 +100,20 @@ var App = React.createClass({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
lbry.checkNewVersionAvailable((isAvailable) => {
|
if (!sessionStorage.getItem('upgradeSkipped')) {
|
||||||
if (!isAvailable || sessionStorage.getItem('upgradeSkipped')) {
|
lbry.checkNewVersionAvailable(({isAvailable}) => {
|
||||||
return;
|
if (!isAvailable) {
|
||||||
}
|
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';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
lbry.getVersionInfo((versionInfo) => {
|
||||||
modal: 'upgrade',
|
this._version = versionInfo.lbrynet_version;
|
||||||
isOldOSX: isOldOSX,
|
this.setState({
|
||||||
updateUrl: updateUrl,
|
modal: 'upgrade',
|
||||||
})
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
},
|
},
|
||||||
openDrawer: function() {
|
openDrawer: function() {
|
||||||
sessionStorage.setItem('drawerOpen', true);
|
sessionStorage.setItem('drawerOpen', true);
|
||||||
|
@ -288,11 +279,7 @@ var App = React.createClass({
|
||||||
<Modal isOpen={this.state.modal == 'upgrade'} contentLabel="Update available"
|
<Modal isOpen={this.state.modal == 'upgrade'} contentLabel="Update available"
|
||||||
type="confirm" confirmButtonLabel="Upgrade" abortButtonLabel="Skip"
|
type="confirm" confirmButtonLabel="Upgrade" abortButtonLabel="Skip"
|
||||||
onConfirmed={this.handleUpgradeClicked} onAborted={this.handleSkipClicked}>
|
onConfirmed={this.handleUpgradeClicked} onAborted={this.handleSkipClicked}>
|
||||||
<p>Your version of LBRY is out of date and may be unreliable or insecure.</p>
|
Your version of LBRY is out of date and may be unreliable or insecure.
|
||||||
{this.state.isOldOSX
|
|
||||||
? <p>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."</p>
|
|
||||||
: null}
|
|
||||||
|
|
||||||
</Modal>
|
</Modal>
|
||||||
<Modal isOpen={this.state.modal == 'downloading'} contentLabel="Downloading Update" type="custom">
|
<Modal isOpen={this.state.modal == 'downloading'} contentLabel="Downloading Update" type="custom">
|
||||||
Downloading Update{this.state.downloadProgress ? `: ${this.state.downloadProgress}%` : null}
|
Downloading Update{this.state.downloadProgress ? `: ${this.state.downloadProgress}%` : null}
|
||||||
|
|
Loading…
Add table
Reference in a new issue