Merge pull request #114 from lbryio/version-info-logic-fix

Don't try to send version info to render process if window isn't open
This commit is contained in:
Jeremy Kauffman 2017-05-05 08:59:24 -04:00 committed by GitHub
commit f5dec02fd9

View file

@ -52,19 +52,25 @@ function checkForNewVersion(callback) {
const [_, remoteVersion] = tagName.match(/^v([\d.]+(?:-?rc\d+)?)$/);
if (!remoteVersion) {
console.log('Malformed remote version string:', tagName);
win.webContents.send('version-info-received', null);
if (win) {
win.webContents.send('version-info-received', null);
}
} else {
console.log('Remote version:', remoteVersion);
const upgradeAvailable = semver.gt(formatRc(remoteVersion), formatRc(localVersion));
console.log(upgradeAvailable ? 'Upgrade available' : 'No upgrade available');
win.webContents.send('version-info-received', {remoteVersion, localVersion, upgradeAvailable});
if (win) {
win.webContents.send('version-info-received', {remoteVersion, localVersion, upgradeAvailable});
}
}
})
});
req.on('error', (err) => {
console.log('Failed to get current version from GitHub. Error:', err);
win.webContents.send('version-info-received', null);
if (win) {
win.webContents.send('version-info-received', null);
}
});
}